/* * ------------------------------------------------------- * Check if string is an identifier * (consists of at least one alpha character followed by * alphanumerics or underline characters in any order) * * Return: * TRUE - identifier * FALSE - otherwise * ------------------------------------------------------- */ int cli_is_id(char *p) { if (!ISALPHA(*p)) return (FALSE); while (*p && (ISALPHA(*p) || ISDIGIT(*p) || *p == '_' )) p++; if (*p) return (FALSE); else return (TRUE); }
static unsigned long insn_extract (char param_ch, char *enc_initial) { char *enc; unsigned long ret = 0; unsigned opc_pos = 32; for (enc = enc_initial; *enc != '\0'; ) if ((*enc == '0') && (*(enc + 1) == 'x')) { unsigned long tmp = strtol (enc+2, NULL, 16); opc_pos -= 4; if (param_ch == '0' || param_ch == '1') { if (param_ch == '0') tmp = 15 - tmp; ret |= tmp << opc_pos; } enc += 3; } else { if (*enc == '0' || *enc == '1' || *enc == '-' || ISALPHA (*enc)) { opc_pos--; if (param_ch == *enc) ret |= 1 << opc_pos; } enc++; } return ret; }
/* * 'string' compare for scanning */ int ipsc_matchstr(sinfo_t *sp, char *str, int n) { char *s, *t, *up; int i = n; if (i > sp->s_len) i = sp->s_len; up = str; for (s = sp->s_txt, t = sp->s_msk; i; i--, s++, t++, up++) switch ((int)*t) { case '.' : if (*s != *up) return 1; break; case '?' : if (!ISALPHA(*up) || ((*s & 0x5f) != (*up & 0x5f))) return 1; break; case '*' : break; } return 0; }
/* Return nonzero if S has any special globbing chars in it. */ static int has_magic(const char *s, int flags) { const int escape = !(flags & FNM_NOESCAPE); const int nocase = flags & FNM_CASEFOLD; register const char *p = s; register char c; while ((c = *p++) != 0) { switch (c) { case '*': case '?': case '[': return 1; case '\\': if (escape && !(c = *p++)) return 0; continue; default: if (!FNM_SYSCASE && ISALPHA(c) && nocase) return 1; } p = Next(p-1); } return 0; }
static char caps_effect(char c) { if (ISALPHA(c) && ISLOWER(c)) return TOUPPER(c); return c; }
const CGEN_KEYWORD_ENTRY * cgen_keyword_lookup_name (CGEN_KEYWORD *kt, const char *name) { const CGEN_KEYWORD_ENTRY *ke; const char *p,*n; if (kt->name_hash_table == NULL) build_keyword_hash_tables (kt); ke = kt->name_hash_table[hash_keyword_name (kt, name, 0)]; /* We do case insensitive comparisons. If that ever becomes a problem, add an attribute that denotes "do case sensitive comparisons". */ while (ke != NULL) { n = name; p = ke->name; while (*p && (*p == *n || (ISALPHA (*p) && (TOLOWER (*p) == TOLOWER (*n))))) ++n, ++p; if (!*p && !*n) return ke; ke = ke->next_name; } if (kt->null_entry) return kt->null_entry; return NULL; }
/* Test if a string is a valid C++ identifier (possibly scope qualified). */ int cxx_scoped_identifier (const char *s) { if (*s != ':') goto no_scope_prefix; while (1) { if (*++s != ':') return 0; ++s; no_scope_prefix: if (!ISALPHA ((unsigned char)*s) && *s != '_') return 0; while (*++s != ':') { if (*s == '\0') return 1; else if (!ISALNUM ((unsigned char)*s) && *s != '_') return 0; } } }
int main(int argc, char const *argv[]) { int len, n, i; char word[MAXWORD]; printf("%d\n", sizeof("abcd")); return 0; while((len = getword(word, MAXWORD)) >= 0) { if (ISALPHA(word[0])) { if ((n = binsearch(word, keytab, NKEYS)) > 0) { keytab[n].count++; } } } for (i = 0; i < NKEYS; ++i) { printf("%s: %d\n", keytab[i].word, keytab[i].count); } return 0; }
static char shift_effect(char c, short code) { if (ISDIGIT(c) || ISSYMBOL(c)) return SCAN_CODES_SYMBOLS[code]; else if (ISALPHA(c) && ISLOWER(c)) return TOUPPER(c); return c; }
/* * Convert a string to an unsigned long integer. * * Ignores `locale' stuff. Assumes that the upper and lower case * alphabets and digits are each contiguous. */ unsigned long strtoul(const char *nptr, char **endptr, register int base) { register const char *s = nptr; register unsigned long acc; register int c; register unsigned long cutoff; register int neg = 0, any, cutlim; /* * See strtol for comments as to the logic used. */ do { c = *s++; } while (ISSPACE(c)); if (c == '-') { neg = 1; c = *s++; } else if (c == '+') c = *s++; if ((base == 0 || base == 16) && c == '0' && (*s == 'x' || *s == 'X')) { c = s[1]; s += 2; base = 16; } if (base == 0) base = c == '0' ? 8 : 10; cutoff = (unsigned long)ULONG_MAX / (unsigned long)base; cutlim = (unsigned long)ULONG_MAX % (unsigned long)base; for (acc = 0, any = 0;; c = *s++) { if (ISDIGIT(c)) c -= '0'; else if (ISALPHA(c)) c -= ISUPPER(c) ? 'A' - 10 : 'a' - 10; else break; if (c >= base) break; if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) any = -1; else { any = 1; acc *= base; acc += c; } } if (any < 0) { acc = ULONG_MAX; errno = ERANGE; } else if (neg) acc = -acc; if (endptr != 0) *endptr = (char *) (any ? s - 1 : nptr); return (acc); }
yylex() { register c; int i; if (pass == PASS_1) { /* scan the input file */ do c = nextchar(); while (isspace(c) && c != '\n'); if (ISALPHA(c)) c = inident(c); else if (isdigit(c)) c = innumber(c); else switch (c) { case '=': case '<': case '>': case '|': case '&': c = induo(c); break; case ASC_SQUO: case ASC_DQUO: c = instring(c); break; case ASC_COMM: do c = nextchar(); while (c != '\n' && c != '\0'); break; case CTRL('A'): c = CODE1; readcode(1); break; case CTRL('B'): c = CODE2; readcode(2); break; case CTRL('C'): c = CODE4; readcode(4); break; } /* produce the intermediate token file */ if (c <= 0) return(0); if (c <= 127) putc(c, tempfile); else putval(c); } else { /* read from intermediate token file */ c = getc(tempfile); if (c == EOF) return(0); if (c > 127) { c += 128; c = getval(c); } } return(c); }
static int parsekeyword(unsigned char **pattern, unsigned char *charset) { parsekey_state state = CURLFNM_PKW_INIT; #define KEYLEN 10 char keyword[KEYLEN] = { 0 }; int found = FALSE; int i; unsigned char *p = *pattern; for(i = 0; !found; i++) { char c = *p++; if(i >= KEYLEN) return SETCHARSET_FAIL; switch(state) { case CURLFNM_PKW_INIT: if(ISALPHA(c) && ISLOWER(c)) keyword[i] = c; else if(c == ':') state = CURLFNM_PKW_DDOT; else return 0; break; case CURLFNM_PKW_DDOT: if(c == ']') found = TRUE; else return SETCHARSET_FAIL; } } #undef KEYLEN *pattern = p; /* move caller's pattern pointer */ if(strcmp(keyword, "digit") == 0) charset[CURLFNM_DIGIT] = 1; else if(strcmp(keyword, "alnum") == 0) charset[CURLFNM_ALNUM] = 1; else if(strcmp(keyword, "alpha") == 0) charset[CURLFNM_ALPHA] = 1; else if(strcmp(keyword, "xdigit") == 0) charset[CURLFNM_XDIGIT] = 1; else if(strcmp(keyword, "print") == 0) charset[CURLFNM_PRINT] = 1; else if(strcmp(keyword, "graph") == 0) charset[CURLFNM_GRAPH] = 1; else if(strcmp(keyword, "space") == 0) charset[CURLFNM_SPACE] = 1; else if(strcmp(keyword, "blank") == 0) charset[CURLFNM_BLANK] = 1; else if(strcmp(keyword, "upper") == 0) charset[CURLFNM_UPPER] = 1; else if(strcmp(keyword, "lower") == 0) charset[CURLFNM_LOWER] = 1; else return SETCHARSET_FAIL; return SETCHARSET_OK; }
/* Test if a string is a valid C identifier. */ int c_identifier (const char *s) { if (!ISALPHA ((unsigned char)*s) && *s != '_') return 0; while (*++s != '\0') if (!ISALNUM ((unsigned char)*s) && *s != '_') return 0; return 1; }
PyObject* _Py_bytes_isalpha(const char *cptr, Py_ssize_t len) { register const unsigned char *p = (unsigned char *) cptr; register const unsigned char *e; /* Shortcut for single character strings */ if (len == 1 && ISALPHA(*p)) Py_RETURN_TRUE; /* Special case for empty strings */ if (len == 0) Py_RETURN_FALSE; e = p + len; for (; p < e; p++) { if (!ISALPHA(*p)) Py_RETURN_FALSE; } Py_RETURN_TRUE; }
match gfc_match_defined_op_name (char *result, int error_flag) { static const char * const badops[] = { "and", "or", "not", "eqv", "neqv", "eq", "ne", "ge", "le", "lt", "gt", NULL }; char name[GFC_MAX_SYMBOL_LEN + 1]; locus old_loc; match m; int i; old_loc = gfc_current_locus; m = gfc_match (" . %n .", name); if (m != MATCH_YES) return m; /* .true. and .false. have interpretations as constants. Trying to use these as operators will fail at a later time. */ if (strcmp (name, "true") == 0 || strcmp (name, "false") == 0) { if (error_flag) goto error; gfc_current_locus = old_loc; return MATCH_NO; } for (i = 0; badops[i]; i++) if (strcmp (badops[i], name) == 0) goto error; for (i = 0; name[i]; i++) if (!ISALPHA (name[i])) { gfc_error ("Bad character %qc in OPERATOR name at %C", name[i]); return MATCH_ERROR; } strcpy (result, name); return MATCH_YES; error: gfc_error ("The name %qs cannot be used as a defined operator at %C", name); gfc_current_locus = old_loc; return MATCH_ERROR; }
char* parse_id(char **p) { char* ret = (char*)malloc(32); int len = 0; while( ISNUMERIC(**p) || ISALPHA(**p) || **p == '_' ) { if( len < 30) ret[len++] = **p; (*p)++; } if(**p == '%' || **p == '$') ret[len++] = *((*p)++); ret[len] = 0; return ret; }
bool isAlpDig(std::string &src) { std::string::iterator it = src.begin(); bool flag = true; for (; it != src.end(); ++it) { if (!ISALPHA(*it) && !ISDIGIT(*it)) { flag = false; break; } } if (flag) return true; else return false; }
const char * dos_lbasename (const char *name) { const char *base; /* Skip over a possible disk name. */ if (ISALPHA (name[0]) && name[1] == ':') name += 2; for (base = name; *name; name++) if (IS_DOS_DIR_SEPARATOR (*name)) base = name + 1; return base; }
static int is_valid_c_symbol_name(const char *name) { const char *c = NULL; if (name == NULL || name[0] == '\0') return 0; if (!ISALPHA(name[0]) && name[0] != '_') return 0; c = &name[1]; for (; *c != '\0'; ++c) { if (!ISALNUM(*c) && *c != '_') return 0; } return 1; }
static mrb_bool is_valid_c_symbol_name(const char *name) { const char *c = NULL; if (name == NULL || name[0] == '\0') return FALSE; if (!ISALPHA(name[0]) && name[0] != '_') return FALSE; c = &name[1]; for (; *c != '\0'; ++c) { if (!ISALNUM(*c) && *c != '_') return FALSE; } return TRUE; }
int check_macro (const char *line, sb *expand, const char **error, macro_entry **info) { const char *s; char *copy, *cs; macro_entry *macro; sb line_sb; if (! ISALPHA (*line) && *line != '_' && *line != '$' && (! macro_mri || *line != '.')) return 0; s = line + 1; while (ISALNUM (*s) || *s == '_' || *s == '$') ++s; copy = (char *) alloca (s - line + 1); memcpy (copy, line, s - line); copy[s - line] = '\0'; for (cs = copy; *cs != '\0'; cs++) *cs = TOLOWER (*cs); macro = (macro_entry *) hash_find (macro_hash, copy); if (macro == NULL) return 0; /* Wrap the line up in an sb. */ sb_new (&line_sb); while (*s != '\0' && *s != '\n' && *s != '\r') sb_add_char (&line_sb, *s++); sb_new (expand); *error = macro_expand (0, &line_sb, macro, expand); sb_kill (&line_sb); /* Export the macro information if requested. */ if (info) *info = macro; return 1; }
void ByteStringExtractor::extractStrings(const TCHAR *fname) { FILE *f = FOPEN(fname, _T("rb")); setvbuf(f, NULL, _IOFBF, 0x10000); int ch; m_strLength = 0; while((ch = fgetc(f)) != EOF) { if(ISALPHA(ch)) { appendChar(ch); } else { outputString(); } } outputString(); fclose(f); }
static int get_def_time_unit(const char *name, const char *defval) { const char *cp; for (cp = mail_conf_eval(defval); /* void */ ; cp++) { if (*cp == 0) msg_panic("parameter %s: missing time unit in default value: %s", name, defval); if (ISALPHA(*cp)) { if (cp[1] != 0) msg_panic("parameter %s: bad time unit in default value: %s", name, defval); return (*cp); } } }
static bool parse_bool (const char **pp, const char *end, unsigned int *pv) { parse_space (pp, end); const char *p = *pp; while (*pp < end && ISALPHA(**pp)) (*pp)++; /* CSS allows on/off as aliases 1/0. */ if (*pp - p == 2 || 0 == strncmp (p, "on", 2)) *pv = 1; else if (*pp - p == 3 || 0 == strncmp (p, "off", 2)) *pv = 0; else return false; return true; }
char * basename (const char *name) { const char *base; #if defined (HAVE_DOS_BASED_FILE_SYSTEM) /* Skip over the disk name in MSDOS pathnames. */ if (ISALPHA (name[0]) && name[1] == ':') name += 2; #endif for (base = name; *name; name++) { if (IS_DIR_SEPARATOR (*name)) { base = name + 1; } } return (char *) base; }
boolean kpse_absolute_p P1C(string, filename) { #ifdef VMS #include <string.h> return strcspn (filename, "]>:") != strlen (filename); #else /* not VMS */ boolean absolute = IS_DIR_SEP (*filename) #ifdef DOS || ISALPHA (*filename) && filename[1] == ':' #endif /* DOS */ ; boolean explicit_relative = (*filename == '.' && (IS_DIR_SEP (filename[1]) || (filename[1] == '.' && IS_DIR_SEP (filename[2])))); return absolute || explicit_relative; #endif /* not VMS */ }
/* Output ITEM, of length ITEM_WIDTH, in the left column, followed by word-wrapped HELP in a second column. */ static void wrap_help (const char *help, const char *item, unsigned int item_width) { unsigned int col_width = 27; unsigned int remaining, room, len; remaining = strlen (help); do { room = columns - 3 - MAX (col_width, item_width); if (room > columns) room = 0; len = remaining; if (room < len) { unsigned int i; for (i = 0; help[i]; i++) { if (i >= room && len != remaining) break; if (help[i] == ' ') len = i; else if ((help[i] == '-' || help[i] == '/') && help[i + 1] != ' ' && i > 0 && ISALPHA (help[i - 1])) len = i + 1; } } printf( " %-*.*s %.*s\n", col_width, item_width, item, len, help); item_width = 0; while (help[len] == ' ') len++; help += len; remaining -= len; } while (remaining); }
int main() { char ch;int x,y; printf("enter the character you want to enter?\n"); scanf("%c",&ch); if(ISLOWER(ch)) printf("the character is lowercase\n"); if(ISUPPER(ch)) printf("the character is uppercase\n"); if(ISALPHA(ch)) printf("the character is an alphabet\n"); else printf("the character is not an alphabet\n"); printf("Enter the two nos you want to compare\n"); scanf("%d%d",&x,&y); printf("the bigger no is %d\n",ISBIG(x,y)); return 0; }
static __inline char * db_randomsym(size_t *lenp) { extern db_symtab_t db_symtabs[]; db_symtab_t *stab; int nsymtabs, nsyms; char *p, *q; struct db_hang_forall_arg dfa; for (nsymtabs = 0; db_symtabs[nsymtabs].name != NULL; nsymtabs++) ; if (nsymtabs == 0) return (NULL); stab = &db_symtabs[db_random(nsymtabs)]; dfa.cnt = 0; X_db_forall(stab, db_hang_forall, &dfa); nsyms = -dfa.cnt; if (nsyms == 0) return (NULL); dfa.cnt = db_random(nsyms); X_db_forall(stab, db_hang_forall, &dfa); q = db_qualify(dfa.sym, stab->name); /* don't show symtab name if there are less than 3 of 'em */ if (nsymtabs < 3) while (*q++ != ':'); /* strlen(q) && ignoring underscores and colons */ for ((*lenp) = 0, p = q; *p; p++) if (ISALPHA(*p)) (*lenp)++; return (q); }
static int get_token (int idx, sb *in, sb *name) { if (idx < in->len && (ISALPHA (in->ptr[idx]) || in->ptr[idx] == '_' || in->ptr[idx] == '$')) { sb_add_char (name, in->ptr[idx++]); while (idx < in->len && (ISALNUM (in->ptr[idx]) || in->ptr[idx] == '_' || in->ptr[idx] == '$')) { sb_add_char (name, in->ptr[idx++]); } } /* Ignore trailing &. */ if (macro_alternate && idx < in->len && in->ptr[idx] == '&') idx++; return idx; }