home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 113 / EnigmaAmiga113CD.iso / software / sviluppo / sed-3.02 / sed / basicdefs.h next >
Encoding:
C/C++ Source or Header  |  1998-07-04  |  3.8 KB  |  116 lines

  1. /*  GNU SED, a batch stream editor.
  2.     Copyright (C) 1998 Free Software Foundation, Inc.
  3.  
  4.     This program is free software; you can redistribute it and/or modify
  5.     it under the terms of the GNU General Public License as published by
  6.     the Free Software Foundation; either version 2, or (at your option)
  7.     any later version.
  8.  
  9.     This program is distributed in the hope that it will be useful,
  10.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.     GNU General Public License for more details.
  13.  
  14.     You should have received a copy of the GNU General Public License
  15.     along with this program; if not, write to the Free Software
  16.     Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  17.  
  18. /* some basic #defines to support pre-ANSI compilers */
  19.  
  20. #ifndef BASICDEFS_H
  21. #define BASICDEFS_H
  22.  
  23. /* Can the compiler grok function prototypes? */
  24. #if defined __STDC__ && __STDC__
  25. # define P_(s)        s
  26. #else
  27. # define P_(s)        ()
  28. #endif
  29.  
  30. /* (VOID *) is the generic pointer type; some ancient compilers
  31.    don't know about (void *), and typically use (char *) instead.
  32.    VCAST() is used to cast to and from (VOID *)s --- but if the
  33.    compiler *does* support (void *) make this a no-op, so that
  34.    the compiler can detect if we omitted an essential function
  35.    declaration somewhere.
  36.  */
  37. #ifndef VOID
  38. # define VOID        void
  39. # define VCAST(t)    
  40. #else
  41. # define VCAST(t)    (t)
  42. #endif
  43.  
  44. /* some basic definitions to avoid undue promulgating of VCAST ugliness */
  45. #define MALLOC(n,t)    (VCAST(t *)ck_malloc((n)*sizeof(t)))
  46. #define REALLOC(x,n,t)    (VCAST(t *)ck_realloc(VCAST(VOID *)(x),(n)*sizeof(t)))
  47. #define MEMDUP(x,n,t)    (VCAST(t *)ck_memdup(VCAST(VOID *)(x),(n)*sizeof(t)))
  48. #define FREE(x)        (ck_free(VCAST(VOID *)x))
  49.  
  50.  
  51. #ifdef HAVE_MEMORY_H
  52. # include <memory.h>
  53. #endif
  54.  
  55. #ifndef HAVE_MEMMOVE
  56. # ifndef memmove
  57.    /* ../lib/libsed.a provides a memmove() if the system doesn't.
  58.       Here is where we declare its return type; we don't prototype
  59.       it because that sometimes causes problems when we're running in
  60.       bootstrap mode on a system which really does support memmove(). */
  61.    extern VOID *memmove();
  62. # endif
  63. #endif
  64.  
  65. #ifndef HAVE_MEMCPY
  66. # ifndef memcpy
  67. #  define memcpy(d, s, n)    memmove(d, s, n)
  68. # endif
  69. #endif
  70.  
  71. #ifndef HAVE_STRERROR
  72.  extern char *strerror P_((int e));
  73. #endif
  74.  
  75.  
  76. /* handle misdesigned <ctype.h> macros (snarfed from lib/regex.c) */
  77. /* Jim Meyering writes:
  78.  
  79.    "... Some ctype macros are valid only for character codes that
  80.    isascii says are ASCII (SGI's IRIX-4.0.5 is one such system --when
  81.    using /bin/cc or gcc but without giving an ansi option).  So, all
  82.    ctype uses should be through macros like ISPRINT...  If
  83.    STDC_HEADERS is defined, then autoconf has verified that the ctype
  84.    macros don't need to be guarded with references to isascii. ...
  85.    Defining isascii to 1 should let any compiler worth its salt
  86.    eliminate the && through constant folding."
  87.    Solaris defines some of these symbols so we must undefine them first.  */
  88.  
  89. #undef ISASCII
  90. #if defined STDC_HEADERS || (!defined isascii && !defined HAVE_ISASCII)
  91. # define ISASCII(c) 1
  92. #else
  93. # define ISASCII(c) isascii(c)
  94. #endif
  95.  
  96. #ifdef isblank
  97. # define ISBLANK(c) (ISASCII (c) && isblank (c))
  98. #else
  99. # define ISBLANK(c) ((c) == ' ' || (c) == '\t')
  100. #endif
  101.  
  102. #undef ISPRINT
  103. #define ISPRINT(c) (ISASCII (c) && isprint (c))
  104. #define ISDIGIT(c) (ISASCII (c) && isdigit (c))
  105. #define ISALNUM(c) (ISASCII (c) && isalnum (c))
  106. #define ISALPHA(c) (ISASCII (c) && isalpha (c))
  107. #define ISCNTRL(c) (ISASCII (c) && iscntrl (c))
  108. #define ISLOWER(c) (ISASCII (c) && islower (c))
  109. #define ISPUNCT(c) (ISASCII (c) && ispunct (c))
  110. #define ISSPACE(c) (ISASCII (c) && isspace (c))
  111. #define ISUPPER(c) (ISASCII (c) && isupper (c))
  112. #define ISXDIGIT(c) (ISASCII (c) && isxdigit (c))
  113.  
  114.  
  115. #endif /*!BASICDEFS_H*/
  116.