home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / program / lynxlib / nstring.c < prev    next >
C/C++ Source or Header  |  1993-10-23  |  2KB  |  68 lines

  1. /* This source file is part of the LynxLib miscellaneous library by
  2. Robert Fischer, and is Copyright 1990 by Robert Fischer.  It costs no
  3. money, and you may not make money off of it, but you may redistribute
  4. it.  It comes with ABSOLUTELY NO WARRANTY.  See the file LYNXLIB.DOC
  5. for more details.
  6. To contact the author:
  7.     Robert Fischer \\80 Killdeer Rd \\Hamden, CT   06517   USA
  8.     (203) 288-9599     fischer-robert@cs.yale.edu                 */
  9.  
  10. #include <ctype.h>
  11. #include <stddef.h>
  12. /* ---------------------------------------------------------------- */
  13. char *pstrupper(s)    /* Converts string to upper case */
  14. register char *s;
  15. {
  16.     for (; *s != NIL; s++) {
  17.         if (islower(*s)) *s += 'A' - 'a';
  18.     }
  19.     return s;
  20. }
  21. /* ---------------------------------------------------------------- */
  22. char *strlower(s)    /* Converts string to lower case */
  23. register char *s;
  24. {
  25.     for (; *s != NIL; s++) {
  26.         if (isupper(*s)) *s = _tolower(*s);
  27.     }
  28.     return s;
  29. }
  30. /* ---------------------------------------------------------------- */
  31. char *pstrcpy(dest, source)
  32. /* Does a strcpy, but returns the address of the NIL in dest */
  33. register char *dest;
  34. register char *source;
  35. {
  36.     while (*source != NIL) *dest++ = *source++;
  37.     *dest = NIL;
  38.     return dest;
  39. }
  40. /* ---------------------------------------------------------------- */
  41. char *pstrcat(dest, source)
  42. /* Does a strcat, but returns address of the NIL in dest */
  43. register char *dest;
  44. register char *source;
  45. {
  46.     while (*dest != NIL) dest++;
  47.     while (*source != NIL) *dest++ = *source++;
  48.     *dest = NIL;
  49.     return dest;
  50. }
  51. /* ---------------------------------------------------------------- */
  52. char *strdup(string)
  53. register char *string;
  54. {
  55. register char *p;
  56.  
  57.     if(p = malloc(strlen(string) + 1))
  58.         strcpy(p, string);
  59.     return(p);
  60. }
  61. /* ---------------------------------------------------------------- */
  62. char *pstrlen(s)
  63. char *s;
  64. {
  65.     return s + strlen(s);
  66. }
  67. /* ---------------------------------------------------------------- */
  68.