Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. /*
  2.  * Tiny BASIC Interpreter and Compiler Project
  3.  * Common service routines module
  4.  *
  5.  * Released as Public Domain by Damian Gareth Walker 2019
  6.  * Created: 20-Sep-2019
  7.  */
  8.  
  9.  
  10. /* included headers */
  11. #include <stdio.h>
  12. #include <stdlib.h>
  13. #include <string.h>
  14. #include <ctype.h>
  15. #include "common.h"
  16.  
  17.  
  18. /*
  19.  * Top Level Routines
  20.  */
  21.  
  22.  
  23. /*
  24.  * Portable case-insensitive comparison
  25.  * params:
  26.  *   char*   a   string to compare
  27.  *   char*   b   string to compare to
  28.  * returns:
  29.  *   int         -1 if a<b, 0 if a==b, 1 if a>b
  30.  */
  31. int tinybasic_strcmp (char *a, char *b) {
  32.   do {
  33.     if (toupper (*a) != toupper (*b))
  34.       return (toupper (*a) > toupper (*b))
  35.         - (toupper (*a) < toupper (*b));
  36.     else {
  37.       a++;
  38.       b++;
  39.     }
  40.   } while (*a && *b);
  41.   return 0;
  42. }
  43.  
  44.