]> granicus.if.org Git - multimarkdown/commitdiff
UPDATE: Use custom strdup() replacement
authorFletcher T. Penney <fletcher@fletcherpenney.net>
Tue, 4 Jul 2017 13:06:06 +0000 (09:06 -0400)
committerFletcher T. Penney <fletcher@fletcherpenney.net>
Tue, 4 Jul 2017 13:06:06 +0000 (09:06 -0400)
Sources/libMultiMarkdown/odf.c

index 59810b2cd173f421213ec6c107c0adaa4b58a90f..0a8063a124d8b9d37da7c3668e11ec4bc5beea05 100644 (file)
 #define print_localized(x) mmd_print_localized_char_odf(out, x, scratch)
 
 
+/// strdup() not available on all platforms
+static char * my_strdup(const char * source) {
+       char * result = malloc(strlen(source) + 1);
+
+       if (result) {
+               strcpy(result, source);
+       }
+
+       return result;
+}
+
+
 void mmd_print_char_odf(DString * out, char c) {
        switch (c) {
                case '"':
@@ -224,7 +236,7 @@ static char * correct_dimension_units(char *original) {
        char *result;
        int i;
        
-       result = strdup(original);
+       result = my_strdup(original);
        
        for (i = 0; result[i]; i++)
                result[i] = tolower(result[i]);
@@ -1063,7 +1075,7 @@ void mmd_export_token_odf(DString * out, const char * source, token * t, scratch
 
                                        if (strcmp(temp_char2, "notcited") == 0) {
                                                free(temp_char);
-                                               temp_char = strdup("");
+                                               temp_char = my_strdup("");
                                                temp_bool = false;
                                        }
 
@@ -1074,7 +1086,7 @@ void mmd_export_token_odf(DString * out, const char * source, token * t, scratch
                                } else {
                                        // This is the actual citation (e.g. `[#foo]`)
                                        // No locator
-                                       temp_char = strdup("");
+                                       temp_char = my_strdup("");
                                }
 
                                // Classify this use