Changeset 492


Ignore:
Timestamp:
Aug 1, 2003, 3:44:59 AM (22 years ago)
Author:
bird
Message:

#483: Added uppercasing strpool_add* variants.

Location:
trunk/src/emx/src/emxomf
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/emx/src/emxomf/grow.c

    • Property cvs2svn:cvs-rev changed from 1.3 to 1.4
    r491 r492  
    3636#include <stdlib.h>
    3737#include <string.h>
     38#include <ctype.h>
    3839#include "defs.h"
    3940#include "grow.h"
     
    332333  return strpool_addn (p, s, strlen (s));
    333334}
     335
     336/* Add the uppercased string S of LEN characters to the string pool P.
     337   See strpool_addn for more details. */
     338
     339const char *strpool_addnu (struct strpool *p, const char *s, int len)
     340{
     341  unsigned hash;
     342  int i;
     343  struct string *v;
     344
     345  hash = 0;
     346  for (i = 0; i < len; ++i)
     347      hash = hash * 65599 + toupper(s[i]);
     348  hash %= STRPOOL_HASH_SIZE;
     349  for (v = p->table[hash]; v != NULL; v = v->next)
     350    if (strlen (v->string) == len && memcmp (v->string, s, len) == 0)
     351      return v->string;
     352  v = xmalloc (sizeof (*v) + len);
     353  memcpy (v->string, s, len);
     354  v->string[len] = 0;
     355  strupr(v->string);
     356  v->next = p->table[hash];
     357  p->table[hash] = v;
     358  return v->string;
     359}
     360
     361/* Add the null-terminated uppercased string S to the string pool P.
     362   See strpool_add for more details. */
     363
     364const char *strpool_addu (struct strpool *p, const char *s)
     365{
     366  if (s == NULL)
     367    return NULL;
     368  return strpool_addnu (p, s, strlen (s));
     369}
     370
  • trunk/src/emx/src/emxomf/grow.h

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r491 r492  
    5959const char *strpool_addn (struct strpool *p, const char *s, int len);
    6060const char *strpool_add (struct strpool *p, const char *s);
     61const char *strpool_addnu ( struct strpool *p, const char *s, int len);
     62const char *strpool_addu ( struct strpool *p, const char *s);
Note: See TracChangeset for help on using the changeset viewer.