You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2011/12/11 05:29:25 UTC
[lucy-commits] svn commit: r1212965 - in /incubator/lucy/trunk/clownfish/src: CFCClass.c
CFCDocuComment.c CFCDumpable.c CFCFile.c CFCFunction.c CFCMethod.c
CFCParcel.c CFCSymbol.c CFCType.c CFCUtil.c
Author: marvin
Date: Sun Dec 11 04:29:25 2011
New Revision: 1212965
URL: http://svn.apache.org/viewvc?rev=1212965&view=rev
Log:
Update CFCUtil_die and CFCUtil_warn.
Make CFCUtil_die and CFCUtil_warn go through Perl exception/warning mechanism.
Replace all instances of croak() with CFCUtil_die().
Modified:
incubator/lucy/trunk/clownfish/src/CFCClass.c
incubator/lucy/trunk/clownfish/src/CFCDocuComment.c
incubator/lucy/trunk/clownfish/src/CFCDumpable.c
incubator/lucy/trunk/clownfish/src/CFCFile.c
incubator/lucy/trunk/clownfish/src/CFCFunction.c
incubator/lucy/trunk/clownfish/src/CFCMethod.c
incubator/lucy/trunk/clownfish/src/CFCParcel.c
incubator/lucy/trunk/clownfish/src/CFCSymbol.c
incubator/lucy/trunk/clownfish/src/CFCType.c
incubator/lucy/trunk/clownfish/src/CFCUtil.c
Modified: incubator/lucy/trunk/clownfish/src/CFCClass.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/src/CFCClass.c?rev=1212965&r1=1212964&r2=1212965&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/src/CFCClass.c (original)
+++ incubator/lucy/trunk/clownfish/src/CFCClass.c Sun Dec 11 04:29:25 2011
@@ -272,9 +272,9 @@ CFCClass_register(CFCClass *self) {
CFCClass *existing = CFCClass_fetch_singleton(parcel, class_name);
const char *key = self->full_struct_sym;
if (existing) {
- croak("New class %s conflicts with existing class %s",
- CFCClass_get_class_name(self),
- CFCClass_get_class_name(existing));
+ CFCUtil_die("New class %s conflicts with existing class %s",
+ CFCClass_get_class_name(self),
+ CFCClass_get_class_name(existing));
}
registry[registry_size].key = CFCUtil_strdup(key);
registry[registry_size].klass = (CFCClass*)CFCBase_incref((CFCBase*)self);
@@ -295,7 +295,7 @@ CFCClass_fetch_singleton(CFCParcel *parc
size_t struct_sym_len = strlen(struct_sym);
const size_t MAX_LEN = 256;
if (prefix_len + struct_sym_len > MAX_LEN) {
- croak("names too long: '%s', '%s'", prefix, struct_sym);
+ CFCUtil_die("names too long: '%s', '%s'", prefix, struct_sym);
}
char key[MAX_LEN + 1];
sprintf(key, "%s%s", prefix, struct_sym);
@@ -323,7 +323,7 @@ CFCClass_clear_registry(void) {
void
CFCClass_add_child(CFCClass *self, CFCClass *child) {
CFCUTIL_NULL_CHECK(child);
- if (self->tree_grown) { croak("Can't call add_child after grow_tree"); }
+ if (self->tree_grown) { CFCUtil_die("Can't call add_child after grow_tree"); }
self->num_kids++;
size_t size = (self->num_kids + 1) * sizeof(CFCClass*);
self->children = (CFCClass**)REALLOCATE(self->children, size);
@@ -336,7 +336,7 @@ void
CFCClass_add_function(CFCClass *self, CFCFunction *func) {
CFCUTIL_NULL_CHECK(func);
if (self->tree_grown) {
- croak("Can't call add_function after grow_tree");
+ CFCUtil_die("Can't call add_function after grow_tree");
}
self->num_functions++;
size_t size = (self->num_functions + 1) * sizeof(CFCFunction*);
@@ -350,10 +350,10 @@ void
CFCClass_add_method(CFCClass *self, CFCMethod *method) {
CFCUTIL_NULL_CHECK(method);
if (self->tree_grown) {
- croak("Can't call add_method after grow_tree");
+ CFCUtil_die("Can't call add_method after grow_tree");
}
if (self->is_inert) {
- croak("Can't add_method to an inert class");
+ CFCUtil_die("Can't add_method to an inert class");
}
self->num_methods++;
size_t size = (self->num_methods + 1) * sizeof(CFCMethod*);
@@ -367,7 +367,7 @@ void
CFCClass_add_member_var(CFCClass *self, CFCVariable *var) {
CFCUTIL_NULL_CHECK(var);
if (self->tree_grown) {
- croak("Can't call add_member_var after grow_tree");
+ CFCUtil_die("Can't call add_member_var after grow_tree");
}
self->num_member_vars++;
size_t size = (self->num_member_vars + 1) * sizeof(CFCVariable*);
@@ -381,7 +381,7 @@ void
CFCClass_add_inert_var(CFCClass *self, CFCVariable *var) {
CFCUTIL_NULL_CHECK(var);
if (self->tree_grown) {
- croak("Can't call add_inert_var after grow_tree");
+ CFCUtil_die("Can't call add_inert_var after grow_tree");
}
self->num_inert_vars++;
size_t size = (self->num_inert_vars + 1) * sizeof(CFCVariable*);
@@ -393,9 +393,9 @@ CFCClass_add_inert_var(CFCClass *self, C
void
CFCClass_add_attribute(CFCClass *self, const char *name, const char *value) {
- if (!name || !strlen(name)) { croak("'name' is required"); }
+ if (!name || !strlen(name)) { CFCUtil_die("'name' is required"); }
if (CFCClass_has_attribute(self, name)) {
- croak("Attribute '%s' already registered", name);
+ CFCUtil_die("Attribute '%s' already registered", name);
}
CFCClassAttribute *attribute
= (CFCClassAttribute*)MALLOCATE(sizeof(CFCClassAttribute));
@@ -425,7 +425,7 @@ S_find_func(CFCFunction **funcs, const c
const size_t MAX_LEN = 128;
char lcsym[MAX_LEN + 1];
size_t sym_len = strlen(sym);
- if (sym_len > MAX_LEN) { croak("sym too long: '%s'", sym); }
+ if (sym_len > MAX_LEN) { CFCUtil_die("sym too long: '%s'", sym); }
size_t i;
for (i = 0; i <= sym_len; i++) {
lcsym[i] = tolower(sym[i]);
@@ -584,7 +584,7 @@ S_create_dumpables(CFCClass *self) {
void
CFCClass_grow_tree(CFCClass *self) {
if (self->tree_grown) {
- croak("Can't call grow_tree more than once");
+ CFCUtil_die("Can't call grow_tree more than once");
}
S_establish_ancestry(self);
S_bequeath_member_vars(self);
Modified: incubator/lucy/trunk/clownfish/src/CFCDocuComment.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/src/CFCDocuComment.c?rev=1212965&r1=1212964&r2=1212965&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/src/CFCDocuComment.c (original)
+++ incubator/lucy/trunk/clownfish/src/CFCDocuComment.c Sun Dec 11 04:29:25 2011
@@ -47,7 +47,7 @@ S_strip(char *comment) {
if (strstr(comment, "/**") != comment
|| strstr(comment, "*/") != (comment + len - 2)
) {
- croak("Malformed comment");
+ CFCUtil_die("Malformed comment");
}
// Capture text minus beginning "/**", ending "*/", and left border.
@@ -129,14 +129,14 @@ CFCDocuComment_parse(const char *raw_tex
// Extract param name.
char *ptr = candidate + sizeof("@param") - 1;
if (!isspace(*ptr) || ptr > text_limit) {
- croak("Malformed @param directive in '%s'", raw_text);
+ CFCUtil_die("Malformed @param directive in '%s'", raw_text);
}
while (isspace(*ptr) && ptr < text_limit) { ptr++; }
char *param_name = ptr;
while ((isalnum(*ptr) || *ptr == '_') && ptr < text_limit) { ptr++; }
size_t param_name_len = ptr - param_name;
if (!param_name_len) {
- croak("Malformed @param directive in '%s'", raw_text);
+ CFCUtil_die("Malformed @param directive in '%s'", raw_text);
}
// Extract param description.
@@ -174,7 +174,7 @@ CFCDocuComment_parse(const char *raw_tex
break;
}
else if (ptr > text_limit) {
- croak("Overran end of string while parsing '%s'", raw_text);
+ CFCUtil_die("Overran end of string while parsing '%s'", raw_text);
}
candidate = strstr(ptr, "@param");
}
Modified: incubator/lucy/trunk/clownfish/src/CFCDumpable.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/src/CFCDumpable.c?rev=1212965&r1=1212964&r2=1212965&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/src/CFCDumpable.c (original)
+++ incubator/lucy/trunk/clownfish/src/CFCDumpable.c Sun Dec 11 04:29:25 2011
@@ -86,7 +86,7 @@ CFCDumpable_add_dumpables(CFCDumpable *s
(void)self;
if (!CFCClass_has_attribute(klass, "dumpable")) {
- croak("Class %s isn't dumpable", CFCClass_get_class_name(klass));
+ CFCUtil_die("Class %s isn't dumpable", CFCClass_get_class_name(klass));
}
// Inherit Dump/Load from parent if no novel member vars.
@@ -138,7 +138,7 @@ S_make_method_obj(CFCClass *klass, const
CFCBase_decref((CFCBase*)dump_type);
}
else {
- croak("Unexpected method_name: '%s'", method_name);
+ CFCUtil_die("Unexpected method_name: '%s'", method_name);
}
CFCMethod *method = CFCMethod_new(klass_parcel, "public", klass_name,
@@ -327,8 +327,8 @@ S_process_dump_member(CFCClass *klass, C
}
size_t needed = strlen(pattern) + name_len * 2 + 20;
if (buf_size < needed) {
- croak("Buffer not big enough (%lu < %lu)",
- (unsigned long)buf_size, (unsigned long)needed);
+ CFCUtil_die("Buffer not big enough (%lu < %lu)",
+ (unsigned long)buf_size, (unsigned long)needed);
}
sprintf(buf, pattern, name, name_len, name);
}
@@ -340,13 +340,14 @@ S_process_dump_member(CFCClass *klass, C
size_t needed = strlen(pattern) + name_len * 3 + 20;
if (buf_size < needed) {
- croak("Buffer not big enough (%lu < %lu)",
- (unsigned long)buf_size, (unsigned long)needed);
+ CFCUtil_die("Buffer not big enough (%lu < %lu)",
+ (unsigned long)buf_size, (unsigned long)needed);
}
sprintf(buf, pattern, name, name, name_len, name);
}
else {
- croak("Don't know how to dump a %s", CFCType_get_specifier(type));
+ CFCUtil_die("Don't know how to dump a %s",
+ CFCType_get_specifier(type));
}
CFCClass_append_autocode(klass, buf);
@@ -371,7 +372,7 @@ S_process_load_member(CFCClass *klass, C
}
if (2 * strlen(type_str) + 100 > sizeof(extraction)) { // play it safe
- croak("type_str too long: '%s'", type_str);
+ CFCUtil_die("type_str too long: '%s'", type_str);
}
if (CFCType_is_integer(type)) {
if (strcmp(specifier, "bool_t") == 0
@@ -393,7 +394,7 @@ S_process_load_member(CFCClass *klass, C
specifier, vtable_var);
}
else {
- croak("Don't know how to load %s", specifier);
+ CFCUtil_die("Don't know how to load %s", specifier);
}
const char *pattern =
@@ -406,8 +407,8 @@ S_process_load_member(CFCClass *klass, C
+ strlen(extraction)
+ 20;
if (buf_size < needed) {
- croak("Buffer not big enough (%lu < %lu)", (unsigned long)buf_size,
- (unsigned long)needed);
+ CFCUtil_die("Buffer not big enough (%lu < %lu)",
+ (unsigned long)buf_size, (unsigned long)needed);
}
sprintf(buf, pattern, name, name_len, name, extraction);
Modified: incubator/lucy/trunk/clownfish/src/CFCFile.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/src/CFCFile.c?rev=1212965&r1=1212964&r2=1212965&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/src/CFCFile.c (original)
+++ incubator/lucy/trunk/clownfish/src/CFCFile.c Sun Dec 11 04:29:25 2011
@@ -153,7 +153,7 @@ CFCFile_add_block(CFCFile *self, CFCBase
self->blocks[num_blocks] = NULL;
}
else {
- croak("Wrong kind of object: '%s'", cfc_class);
+ CFCUtil_die("Wrong kind of object: '%s'", cfc_class);
}
}
@@ -162,11 +162,11 @@ S_some_path(CFCFile *self, char *buf, si
const char *ext) {
size_t needed = CFCFile_path_buf_size(self, base_dir);
if (strlen(ext) > 4) {
- croak("ext cannot be more than 4 characters.");
+ CFCUtil_die("ext cannot be more than 4 characters.");
}
if (needed > buf_size) {
- croak("Need buf_size of %lu, but got %lu", (unsigned long)needed,
- (unsigned long)buf_size);
+ CFCUtil_die("Need buf_size of %lu, but got %lu",
+ (unsigned long)needed, (unsigned long)buf_size);
}
if (base_dir) {
sprintf(buf, "%s" CFCUTIL_PATH_SEP "%s%s", base_dir, self->path_part,
Modified: incubator/lucy/trunk/clownfish/src/CFCFunction.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/src/CFCFunction.c?rev=1212965&r1=1212964&r2=1212965&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/src/CFCFunction.c (original)
+++ incubator/lucy/trunk/clownfish/src/CFCFunction.c Sun Dec 11 04:29:25 2011
@@ -72,7 +72,7 @@ CFCFunction_init(CFCFunction *self, CFCP
CFCUTIL_NULL_CHECK(return_type);
CFCUTIL_NULL_CHECK(param_list);
if (!S_validate_micro_sym(micro_sym)) {
- croak("Invalid micro_sym: '%s'", micro_sym);
+ CFCUtil_die("Invalid micro_sym: '%s'", micro_sym);
}
self->return_type = (CFCType*)CFCBase_incref((CFCBase*)return_type);
self->param_list = (CFCParamList*)CFCBase_incref((CFCBase*)param_list);
Modified: incubator/lucy/trunk/clownfish/src/CFCMethod.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/src/CFCMethod.c?rev=1212965&r1=1212964&r2=1212965&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/src/CFCMethod.c (original)
+++ incubator/lucy/trunk/clownfish/src/CFCMethod.c Sun Dec 11 04:29:25 2011
@@ -92,7 +92,8 @@ CFCMethod_init(CFCMethod *self, CFCParce
int is_final, int is_abstract) {
// Validate macro_sym, derive micro_sym.
if (!S_validate_macro_sym(macro_sym)) {
- croak("Invalid macro_sym: '%s'", macro_sym ? macro_sym : "[NULL]");
+ CFCUtil_die("Invalid macro_sym: '%s'",
+ macro_sym ? macro_sym : "[NULL]");
}
char *micro_sym = CFCUtil_strdup(macro_sym);
size_t i;
@@ -108,7 +109,7 @@ CFCMethod_init(CFCMethod *self, CFCParce
// Verify that the first element in the arg list is a self.
CFCVariable **args = CFCParamList_get_variables(param_list);
- if (!args[0]) { croak("Missing 'self' argument"); }
+ if (!args[0]) { CFCUtil_die("Missing 'self' argument"); }
CFCType *type = CFCVariable_get_type(args[0]);
const char *specifier = CFCType_get_specifier(type);
const char *prefix = CFCMethod_get_prefix(self);
@@ -119,8 +120,8 @@ CFCMethod_init(CFCMethod *self, CFCParce
int mismatch = strcmp(wanted, specifier);
FREEMEM(wanted);
if (mismatch) {
- croak("First arg type doesn't match class: '%s' '%s", class_name,
- specifier);
+ CFCUtil_die("First arg type doesn't match class: '%s' '%s",
+ class_name, specifier);
}
self->macro_sym = CFCUtil_strdup(macro_sym);
@@ -210,13 +211,13 @@ CFCMethod_override(CFCMethod *self, CFCM
if (CFCMethod_final(orig)) {
const char *orig_class = CFCMethod_get_class_name(orig);
const char *my_class = CFCMethod_get_class_name(self);
- croak("Attempt to override final method '%s' from '%s' by '%s'",
- orig->macro_sym, orig_class, my_class);
+ CFCUtil_die("Attempt to override final method '%s' from '%s' by '%s'",
+ orig->macro_sym, orig_class, my_class);
}
if (!CFCMethod_compatible(self, orig)) {
const char *func = CFCMethod_implementing_func_sym(self);
const char *orig_func = CFCMethod_implementing_func_sym(orig);
- croak("Non-matching signatures for %s and %s", func, orig_func);
+ CFCUtil_die("Non-matching signatures for %s and %s", func, orig_func);
}
// Mark the Method as no longer novel.
Modified: incubator/lucy/trunk/clownfish/src/CFCParcel.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/src/CFCParcel.c?rev=1212965&r1=1212964&r2=1212965&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/src/CFCParcel.c (original)
+++ incubator/lucy/trunk/clownfish/src/CFCParcel.c Sun Dec 11 04:29:25 2011
@@ -64,14 +64,14 @@ CFCParcel_singleton(const char *name, co
CFCParcel *existing = registry[i];
if (strcmp(existing->name, name) == 0) {
if (cnick && strcmp(existing->cnick, cnick) != 0) {
- croak("cnick '%s' for parcel '%s' conflicts with '%s'",
- cnick, name, existing->cnick);
+ CFCUtil_die("cnick '%s' for parcel '%s' conflicts with '%s'",
+ cnick, name, existing->cnick);
}
return existing;
}
}
if (i == MAX_PARCELS) {
- croak("Exceeded maximum number of parcels (%d)", MAX_PARCELS);
+ CFCUtil_die("Exceeded maximum number of parcels (%d)", MAX_PARCELS);
}
// Register new parcel.
@@ -114,14 +114,14 @@ CFCParcel*
CFCParcel_init(CFCParcel *self, const char *name, const char *cnick) {
// Validate name.
if (!name || !S_validate_name_or_cnick(name)) {
- croak("Invalid name: '%s'", name ? name : "[NULL]");
+ CFCUtil_die("Invalid name: '%s'", name ? name : "[NULL]");
}
self->name = CFCUtil_strdup(name);
// Validate or derive cnick.
if (cnick) {
if (!S_validate_name_or_cnick(cnick)) {
- croak("Invalid cnick: '%s'", cnick);
+ CFCUtil_die("Invalid cnick: '%s'", cnick);
}
self->cnick = CFCUtil_strdup(cnick);
}
Modified: incubator/lucy/trunk/clownfish/src/CFCSymbol.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/src/CFCSymbol.c?rev=1212965&r1=1212964&r2=1212965&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/src/CFCSymbol.c (original)
+++ incubator/lucy/trunk/clownfish/src/CFCSymbol.c Sun Dec 11 04:29:25 2011
@@ -128,13 +128,13 @@ CFCSymbol_init(CFCSymbol *self, struct C
// Validate.
CFCUTIL_NULL_CHECK(parcel);
if (!S_validate_exposure(exposure)) {
- croak("Invalid exposure: '%s'", exposure ? exposure : "[NULL]");
+ CFCUtil_die("Invalid exposure: '%s'", exposure ? exposure : "[NULL]");
}
if (class_name && !S_validate_class_name(class_name)) {
- croak("Invalid class_name: '%s'", class_name);
+ CFCUtil_die("Invalid class_name: '%s'", class_name);
}
if (!micro_sym || !S_validate_identifier(micro_sym)) {
- croak("Invalid micro_sym: '%s'", micro_sym ? micro_sym : "[NULL]");
+ CFCUtil_die("Invalid micro_sym: '%s'", micro_sym ? micro_sym : "[NULL]");
}
// Derive class_cnick if necessary, then validate.
@@ -150,13 +150,13 @@ CFCSymbol_init(CFCSymbol *self, struct C
}
else if (class_cnick) {
// Sanity check class_cnick without class_name.
- croak("Can't supply class_cnick without class_name");
+ CFCUtil_die("Can't supply class_cnick without class_name");
}
else {
real_cnick = NULL;
}
if (real_cnick && !S_validate_class_cnick(real_cnick)) {
- croak("Invalid class_cnick: '%s'", real_cnick);
+ CFCUtil_die("Invalid class_cnick: '%s'", real_cnick);
}
// Assign.
Modified: incubator/lucy/trunk/clownfish/src/CFCType.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/src/CFCType.c?rev=1212965&r1=1212964&r2=1212965&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/src/CFCType.c (original)
+++ incubator/lucy/trunk/clownfish/src/CFCType.c Sun Dec 11 04:29:25 2011
@@ -129,7 +129,7 @@ CFCType_new_integer(int flags, const cha
width = 0;
}
else {
- croak("Unknown integer specifier: '%s'", specifier);
+ CFCUtil_die("Unknown integer specifier: '%s'", specifier);
}
// Add Charmonizer prefix if necessary.
@@ -173,7 +173,7 @@ CFCType_new_float(int flags, const char
size_t i;
for (i = 0; ; i++) {
if (!float_specifiers[i]) {
- croak("Unknown float specifier: '%s'", specifier);
+ CFCUtil_die("Unknown float specifier: '%s'", specifier);
}
if (strcmp(float_specifiers[i], specifier) == 0) {
break;
@@ -202,13 +202,13 @@ CFCType_new_object(int flags, CFCParcel
int indirection) {
// Validate params.
if (indirection != 1) {
- croak("Parameter 'indirection' can only be 1");
+ CFCUtil_die("Parameter 'indirection' can only be 1");
}
if (!specifier || !strlen(specifier)) {
- croak("Missing required param 'specifier'");
+ CFCUtil_die("Missing required param 'specifier'");
}
if ((flags & CFCTYPE_INCREMENTED) && (flags & CFCTYPE_DECREMENTED)) {
- croak("Can't be both incremented and decremented");
+ CFCUtil_die("Can't be both incremented and decremented");
}
// Use default parcel if none supplied.
@@ -228,7 +228,7 @@ CFCType_new_object(int flags, CFCParcel
char full_specifier[MAX_SPECIFIER_LEN + 1];
char small_specifier[MAX_SPECIFIER_LEN + 1];
if (strlen(prefix) + strlen(specifier) > MAX_SPECIFIER_LEN) {
- croak("Specifier and/or parcel prefix too long");
+ CFCUtil_die("Specifier and/or parcel prefix too long");
}
if (strstr(specifier, prefix) != specifier) {
sprintf(full_specifier, "%s%s", prefix, specifier);
@@ -239,7 +239,7 @@ CFCType_new_object(int flags, CFCParcel
strcpy(small_specifier, specifier + strlen(prefix));
}
if (!CFCSymbol_validate_class_name_component(small_specifier)) {
- croak("Invalid specifier: '%s'", specifier);
+ CFCUtil_die("Invalid specifier: '%s'", specifier);
}
// Cache C representation.
@@ -266,7 +266,7 @@ CFCType*
CFCType_new_composite(int flags, CFCType *child, int indirection,
const char *array) {
if (!child) {
- croak("Missing required param 'child'");
+ CFCUtil_die("Missing required param 'child'");
}
flags |= CFCTYPE_COMPOSITE;
S_check_flags(flags, CFCTYPE_COMPOSITE | CFCTYPE_NULLABLE, "Composite");
@@ -278,7 +278,7 @@ CFCType_new_composite(int flags, CFCType
size_t child_c_len = strlen(child_c_string);
size_t amount = child_c_len + indirection;
if (amount > MAX_LEN) {
- croak("C representation too long");
+ CFCUtil_die("C representation too long");
}
char c_string[MAX_LEN + 1];
strcpy(c_string, child_c_string);
@@ -324,13 +324,13 @@ CFCType_new_arbitrary(CFCParcel *parcel,
const char *prefix = CFCParcel_get_prefix(parcel);
size_t full_len = strlen(prefix) + strlen(specifier);
if (full_len > MAX_SPECIFIER_LEN) {
- croak("Illegal specifier: '%s'", specifier);
+ CFCUtil_die("Illegal specifier: '%s'", specifier);
}
sprintf(full_specifier, "%s%s", prefix, specifier);
}
else {
if (strlen(specifier) > MAX_SPECIFIER_LEN) {
- croak("Illegal specifier: '%s'", specifier);
+ CFCUtil_die("Illegal specifier: '%s'", specifier);
}
strcpy(full_specifier, specifier);
}
@@ -339,7 +339,7 @@ CFCType_new_arbitrary(CFCParcel *parcel,
size_t i, max;
for (i = 0, max = strlen(full_specifier); i < max; i++) {
if (!isalnum(full_specifier[i]) && full_specifier[i] != '_') {
- croak("Illegal specifier: '%s'", full_specifier);
+ CFCUtil_die("Illegal specifier: '%s'", full_specifier);
}
}
@@ -392,7 +392,7 @@ CFCType_equals(CFCType *self, CFCType *o
int
CFCType_similar(CFCType *self, CFCType *other) {
if (!CFCType_is_object(self)) {
- croak("Attempt to call 'similar' on a non-object type");
+ CFCUtil_die("Attempt to call 'similar' on a non-object type");
}
if ((CFCType_const(self) ^ CFCType_const(other))
|| (CFCType_nullable(self) ^ CFCType_nullable(other))
Modified: incubator/lucy/trunk/clownfish/src/CFCUtil.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/src/CFCUtil.c?rev=1212965&r1=1212964&r2=1212965&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/src/CFCUtil.c (original)
+++ incubator/lucy/trunk/clownfish/src/CFCUtil.c Sun Dec 11 04:29:25 2011
@@ -263,25 +263,6 @@ CFCUtil_flength(void *file) {
return len;
}
-void
-CFCUtil_die(const char* format, ...) {
- va_list args;
- va_start(args, format);
- vfprintf(stderr, format, args);
- va_end(args);
- fprintf(stderr, "\n");
- exit(1);
-}
-
-void
-CFCUtil_warn(const char* format, ...) {
- va_list args;
- va_start(args, format);
- vfprintf(stderr, format, args);
- va_end(args);
- fprintf(stderr, "\n");
-}
-
// Note: this has to be defined before including the Perl headers because they
// redefine stat() in an incompatible way on certain systems (Windows).
int
@@ -440,6 +421,27 @@ CFCUtil_closedir(void *dirhandle, const
#include "XSUB.h"
#include "ppport.h"
+void
+CFCUtil_die(const char* format, ...) {
+ SV *errsv = get_sv("@", 1);
+ va_list args;
+ va_start(args, format);
+ sv_vsetpvf_mg(errsv, format, &args);
+ va_end(args);
+ croak(NULL);
+}
+
+void
+CFCUtil_warn(const char* format, ...) {
+ SV *mess = newSVpv("", 0);
+ va_list args;
+ va_start(args, format);
+ sv_vsetpvf(mess, format, &args);
+ va_end(args);
+ fprintf(stderr, "%s\n", SvPV_nolen(mess));
+ SvREFCNT_dec(mess);
+}
+
void*
CFCUtil_make_perl_obj(void *ptr, const char *klass) {
SV *inner_obj = newSV(0);