home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3063 / date-strings.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-03-15  |  1.2 KB  |  58 lines

  1. /*
  2.  *    date-strings.c : Strings used everywhere, parsed from
  3.  *        the app-resources into arrays.
  4.  *
  5.  *    George Ferguson, ferguson@cs.rochester.edu,  27 Feb 1991.
  6.  *
  7.  *    $Id: date-strings.c,v 2.1 91/02/28 11:21:07 ferguson Exp $
  8.  */
  9. #include <stdio.h>
  10. #include <ctype.h>
  11. #include <X11/Intrinsic.h>
  12. #include "app-resources.h"
  13. extern char *program;
  14.  
  15. /*
  16.  * Functions defined here:
  17.  */
  18. void initDateStrings();
  19. static void parseStrings();
  20.  
  21. /*
  22.  * Data defined here:
  23.  */
  24. char *longDowStr[7], *shortDowStr[7], *longMonthStr[12], *shortMonthStr[12];
  25.  
  26. /*    -    -    -    -    -    -    -    -    */
  27.  
  28. void
  29. initDateStrings()
  30. {
  31.     parseStrings(appResources.longDowStrings,longDowStr,7);
  32.     parseStrings(appResources.shortDowStrings,shortDowStr,7);
  33.     parseStrings(appResources.longMonthStrings,longMonthStr,12);
  34.     parseStrings(appResources.shortMonthStrings,shortMonthStr,12);
  35. }
  36.  
  37. static void
  38. parseStrings(s,array,num)
  39. char *s;
  40. char *array[];
  41. int num;
  42. {
  43.     char buf[64];
  44.     int i,n;
  45.  
  46.     for (i = 0; i < num; i++) {
  47.     while (isspace(*s))
  48.         s += 1;
  49.     n = 0;
  50.     while (*s && !isspace(*s) && n < 63)
  51.         buf[n++] = *s++;
  52.     buf[n] = '\0';
  53.     if (n == 63 && *s && !isspace(*s))
  54.         fprintf(stderr,"%s: date-string too long: \"%s...\"\n",program,buf);
  55.     array[i] = XtNewString(buf);
  56.     }
  57. }
  58.