[darwinbuild-changes] [111] trunk/darwinxref/cfutils.c

source_changes at macosforge.org source_changes at macosforge.org
Wed Oct 4 01:47:07 PDT 2006


Revision: 111
          http://trac.macosforge.org/projects/darwinbuild/changeset/111
Author:   kevin
Date:     2006-10-04 01:47:07 -0700 (Wed, 04 Oct 2006)

Log Message:
-----------
- actually return results from functions that say they do

Modified Paths:
--------------
    trunk/darwinxref/cfutils.c

Modified: trunk/darwinxref/cfutils.c
===================================================================
--- trunk/darwinxref/cfutils.c	2005-07-28 21:47:00 UTC (rev 110)
+++ trunk/darwinxref/cfutils.c	2006-10-04 08:47:07 UTC (rev 111)
@@ -88,7 +88,7 @@
                                 if (data) {
                                         CFStringRef str = NULL;
                                         result = CFPropertyListCreateFromXMLData(NULL, data, kCFPropertyListMutableContainers, &str);
-					CFRelease(data);
+                                        CFRelease(data);
                                         if (result == NULL) {
                                                 perror_cfstr(str);
                                         }
@@ -107,16 +107,19 @@
 
 
 int cfprintf(FILE* file, const char* format, ...) {
+		char* cstr;
+		int result;
         va_list args;
         va_start(args, format);
         CFStringRef formatStr = CFStringCreateWithCStringNoCopy(NULL, format, kCFStringEncodingUTF8, kCFAllocatorNull);
         CFStringRef str = CFStringCreateWithFormatAndArguments(NULL, NULL, formatStr, args);
         va_end(args);
-        char* cstr = strdup_cfstr(str);
-        fprintf(file, "%s", cstr);
+        cstr = strdup_cfstr(str);
+        result = fprintf(file, "%s", cstr);
         free(cstr);
         CFRelease(str);
         CFRelease(formatStr);
+		return result;
 }
 
 CFArrayRef dictionaryGetSortedKeys(CFDictionaryRef dictionary) {
@@ -134,10 +137,11 @@
 }
 
 int writePlist(FILE* f, CFPropertyListRef p, int tabs) {
+		int result = 0;
         CFTypeID type = CFGetTypeID(p);
 
         if (tabs == 0) {
-                fprintf(f, "// !$*UTF8*$!\n");
+                result += fprintf(f, "// !$*UTF8*$!\n");
         }
 
         char* t = malloc(tabs+1);
@@ -166,43 +170,44 @@
                 }
                 if (utf8[0] == 0) quote = 1;
 
-                if (quote) fprintf(f, "\"");
+                if (quote) result += fprintf(f, "\"");
                 for (i = 0 ;; ++i) {
                         int c = utf8[i];
                         if (c == 0) break;
                         if (c == '\"' || c == '\\') fprintf(f, "\\");
                         //if (c == '\n') c = 'n';
-                        fprintf(f, "%c", c);
+                        result += fprintf(f, "%c", c);
                 }
-                if (quote) fprintf(f, "\"");
+                if (quote) result += fprintf(f, "\"");
                 free(utf8);
         } else if (type == CFArrayGetTypeID()) {
-                fprintf(f, "(\n");
+                result += fprintf(f, "(\n");
                 int count = CFArrayGetCount(p);
                 for (i = 0; i < count; ++i) {
                         CFTypeRef pp = CFArrayGetValueAtIndex(p, i);
-                        fprintf(f, "%s\t", t);
-                        writePlist(f, pp, tabs+1);
-                        fprintf(f, ",\n");
+                        result += fprintf(f, "%s\t", t);
+                        result += writePlist(f, pp, tabs+1);
+                        result += fprintf(f, ",\n");
                 }
-                fprintf(f, "%s)", t);
+                result += fprintf(f, "%s)", t);
         } else if (type == CFDictionaryGetTypeID()) {
-                fprintf(f, "{\n");
+                result += fprintf(f, "{\n");
                 CFArrayRef keys = dictionaryGetSortedKeys(p);
                 int count = CFArrayGetCount(keys);
                 for (i = 0; i < count; ++i) {
                         CFStringRef key = CFArrayGetValueAtIndex(keys, i);
                         char* utf8 = strdup_cfstr(key);
-                        fprintf(f, "%s\t%s = ", t, utf8);
+                        result += fprintf(f, "%s\t%s = ", t, utf8);
                         free(utf8);
-                        writePlist(f, CFDictionaryGetValue(p,key), tabs+1);
-                        fprintf(f, ";\n");
+                        result += writePlist(f, CFDictionaryGetValue(p,key), tabs+1);
+                        result += fprintf(f, ";\n");
                 }
                 CFRelease(keys);
-                fprintf(f, "%s}", t);
+                result += fprintf(f, "%s}", t);
         }
-        if (tabs == 0) fprintf(f, "\n");
+        if (tabs == 0) result += fprintf(f, "\n");
         free(t);
+		return result;
 }
 
 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/darwinbuild-changes/attachments/20061004/11d2f005/attachment-0001.html


More information about the darwinbuild-changes mailing list