]> git.donarmstrong.com Git - lilypond.git/blobdiff - flower/libc-extension.cc
release: 1.3.19
[lilypond.git] / flower / libc-extension.cc
index d8a9fcd6e4594796ce08bac04d55fb2d6f31e581..7fa57c2ff5a36e3402ad31c0c80b1e32955982f7 100644 (file)
@@ -4,14 +4,18 @@
 
   source file of the flowerlib
 
-  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+  (c)  1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+         Jan Nieuwenhuizen <janneke@gnu.org>
 */
-#include <stdarg.h>
+
+#include <stdio.h>
 #include <string.h>
 #include <ctype.h>
 #include "libc-extension.hh"
 
-
+/*
+  urg: why soo wierd?
+ */
 char* 
 strnlwr (char* start_l ,int n)
 {
@@ -34,6 +38,7 @@ strnupr (char* start_l, int n)
   return start_l;
 }
 
+
 #if !HAVE_MEMMEM
 
 /** locate a substring. #memmem# finds the first occurrence of
@@ -43,8 +48,8 @@ strnupr (char* start_l, int n)
   Manual v1.15, but it is with /usr/include/string.h   */
 
 Byte *
-memmem (Byte const *needle,int needle_len,
-       Byte const *haystack, int haystack_len)
+memmem (Byte const *haystack, int haystack_len,
+       Byte const *needle,int needle_len)
 {
   Byte const * end_haystack = haystack + haystack_len - needle_len + 1;
   Byte const * end_needle = needle + needle_len ;
@@ -56,16 +61,13 @@ memmem (Byte const *needle,int needle_len,
       Byte const *subneedle_l = needle;
       Byte const *subhaystack_l = haystack;
       while (subneedle_l < end_needle) 
-       {
-         if (*subneedle_l++ != *subhaystack_l++)
-           {
-             haystack ++;
-             continue;
-           }
-       }
+        if (*subneedle_l++ != *subhaystack_l++)
+         goto next;
        
       // completed the needle. Gotcha.
       return (Byte *) haystack;
+      next:
+       haystack++;
     }
   return 0;
 }
@@ -110,8 +112,8 @@ strrev (Byte* byte_l, int length_i)
 }
 
 #if ! HAVE_SNPRINTF
-int snprintf (char *str, size_t,
-             char const *format, ...)
+int 
+snprintf (char *str, size_t, char const *format, ...)
 {
   va_list ap;
   va_start (ap, format);
@@ -120,3 +122,13 @@ int snprintf (char *str, size_t,
   return i;
 }
 #endif
+
+#if ! HAVE_VSNPRINTF
+int 
+vsnprintf (char *str, size_t, char const *format, va_list args)
+{
+  int i = vsprintf (str, format, args);
+  return i;
+}
+#endif
+