コード例 #1
0
ファイル: smbencrypt.c プロジェクト: kinkie/squid
void
strupper(char *s)
{
    while (*s) {
#if UNUSED_CODE
#if !defined(KANJI_WIN95_COMPATIBILITY)
        if (lp_client_code_page() == KANJI_CODEPAGE) {

            if (is_shift_jis(*s)) {
                if (is_sj_lower(s[0], s[1]))
                    s[1] = sj_toupper2(s[1]);
                s += 2;
            } else if (is_kana(*s)) {
                s++;
            } else {
                if (islower((int)(unsigned char)*s))
                    *s = toupper((int)(unsigned char)*s);
                s++;
            }
        } else
#endif /* KANJI_WIN95_COMPATIBILITY */
#endif /* UNUSED_CODE */
        {
            if (islower((int)(unsigned char)*s))
                *s = toupper((int)(unsigned char)*s);
            s++;
        }
    }
}
コード例 #2
0
ファイル: kanji.c プロジェクト: AllardJ/Tomato
static char *sj_strtok(char *s1, const char *s2)
{
  static char *s = NULL;
  char *q;
  if (!s1) {
    if (!s) {
      return NULL;
    }
    s1 = s;
  }
  for (q = s1; *s1; ) {
    if (is_shift_jis (*s1)) {
      s1 += 2;
    } else if (is_kana (*s1)) {
      s1++;
    } else {
      char *p = strchr (s2, *s1);
      if (p) {
        if (s1 != q) {
          s = s1 + 1;
          *s1 = '\0';
          return q;
        }
        q = s1 + 1;
      }
      s1++;
    }
  }
  s = NULL;
  if (*q) {
    return q;
  }
  return NULL;
}
コード例 #3
0
ファイル: kanji.c プロジェクト: AllardJ/Tomato
static size_t skip_kanji_multibyte_char(char c)
{
  if(is_shift_jis(c)) {
    return 2;
  } else if (is_kana(c)) {
    return 1;
  }
  return 0;
}
コード例 #4
0
ファイル: util_str.c プロジェクト: ActionLuzifer/mc
/****************************************************************************
does a string have any lowercase chars in it?
****************************************************************************/
BOOL
strhaslower (const char *s)
{
    while (*s)
    {
#if !defined(KANJI_WIN95_COMPATIBILITY)
        /*
         * For completeness we should put in equivalent code for code pages
         * 949 (Korean hangul) and 950 (Big5 Traditional Chinese) here - but
         * doubt anyone wants Samba to behave differently from Win95 and WinNT
         * here. They both treat full width ascii characters as case senstive
         * filenames (ie. they don't do the work we do here).
         * JRA. 
         */

        if (lp_client_code_page () == KANJI_CODEPAGE)
        {
            /* Win95 treats full width ascii characters as case sensitive. */
            if (is_shift_jis (*s))
            {
                if (is_sj_upper (s[0], s[1]))
                    return (True);
                if (is_sj_lower (s[0], s[1]))
                    return (True);
                s += 2;
            }
            else if (is_kana (*s))
            {
                s++;
            }
            else
            {
                if (islower (*s))
                    return (True);
                s++;
            }
        }
        else
#endif /* KANJI_WIN95_COMPATIBILITY */
        {
            size_t skip = skip_multibyte_char (*s);
            if (skip != 0)
                s += skip;
            else
            {
                if (islower (*s))
                    return (True);
                s++;
            }
        }
    }
    return (False);
}
コード例 #5
0
ファイル: kanji.c プロジェクト: AllardJ/Tomato
static char *sj_to_euc(char *from, BOOL overwrite)
{
  char *out;
  char *save;

  save = (char *) from;
  for (out = cvtbuf; *from && (out - cvtbuf < sizeof(cvtbuf)-3);) {
    if (is_shift_jis (*from)) {
      int code = sjis2euc ((int) from[0] & 0xff, (int) from[1] & 0xff);
      *out++ = (code >> 8) & 0xff;
      *out++ = code;
      from += 2;
    } else if (is_kana (*from)) {
コード例 #6
0
ファイル: kanji.c プロジェクト: AllardJ/Tomato
static const char *sj_strchr (const char *s, int c)
{
  for (; *s; ) {
    if (*s == c)
      return (const char *) s;
    if (is_shift_jis (*s)) {
      s += 2;
    } else {
      s++;
    }
  }
  return NULL;
}
コード例 #7
0
ファイル: kanji.c プロジェクト: AllardJ/Tomato
static const char *sj_strrchr(const char *s, int c)
{
  const char *q;

  for (q = 0; *s; ) {
    if (*s == c) {
      q = (const char *) s;
    }
    if (is_shift_jis (*s)) {
      s += 2;
    } else {
      s++;
    }
  }
  return q;
}
コード例 #8
0
ファイル: kanji.c プロジェクト: AllardJ/Tomato
static const char *sj_strstr(const char *s1, const char *s2)
{
  size_t len = strlen (s2);
  if (!*s2) 
    return (const char *) s1;
  for (;*s1;) {
    if (*s1 == *s2) {
      if (strncmp (s1, s2, len) == 0)
        return (const char *) s1;
    }
    if (is_shift_jis (*s1)) {
      s1 += 2;
    } else {
      s1++;
    }
  }
  return NULL;
}
コード例 #9
0
ファイル: mangle.c プロジェクト: tridge/junkcode
/*******************************************************************
  convert a string to upper case
********************************************************************/
void strupper(char *s)
{
    while (*s)
    {
#ifdef KANJI
        if (is_shift_jis (*s)) {
            s += 2;
        } else if (is_kana (*s)) {
            s++;
        } else {
            if (islower(*s))
                *s = toupper(*s);
            s++;
        }
#else
        if (islower(*s))
            *s = toupper(*s);
        s++;
#endif
    }
}
コード例 #10
0
ファイル: util_str.c プロジェクト: BackupTheBerlios/mcvox
/*******************************************************************
  case insensitive string compararison, length limited
********************************************************************/
int StrnCaseCmp(const char *s, const char *t, size_t n)
{
  /* compare until we run out of string, either t or s, or chars */
  /* We *must* use toupper rather than tolower here due to the
     asynchronous upper to lower mapping.
   */
#if !defined(KANJI_WIN95_COMPATIBILITY)
  /*
   * For completeness we should put in equivalent code for code pages
   * 949 (Korean hangul) and 950 (Big5 Traditional Chinese) here - but
   * doubt anyone wants Samba to behave differently from Win95 and WinNT
   * here. They both treat full width ascii characters as case senstive
   * filenames (ie. they don't do the work we do here).
   * JRA. 
   */

  if(lp_client_code_page() == KANJI_CODEPAGE)
  {
    /* Win95 treats full width ascii characters as case sensitive. */
    int diff;
    for (;n > 0;)
    {
      if (!*s || !*t)
        return toupper (*s) - toupper (*t);
      else if (is_sj_alph (*s) && is_sj_alph (*t))
      {
        diff = sj_toupper2 (*(s+1)) - sj_toupper2 (*(t+1));
        if (diff)
          return diff;
        s += 2;
        t += 2;
        n -= 2;
      }
      else if (is_shift_jis (*s) && is_shift_jis (*t))
      {
        diff = ((int) (unsigned char) *s) - ((int) (unsigned char) *t);
        if (diff)
          return diff;
        diff = ((int) (unsigned char) *(s+1)) - ((int) (unsigned char) *(t+1));
        if (diff)
          return diff;
        s += 2;
        t += 2;
        n -= 2;
      }
      else if (is_shift_jis (*s))
        return 1;
      else if (is_shift_jis (*t))
        return -1;
      else 
      {
        diff = toupper (*s) - toupper (*t);
        if (diff)
          return diff;
        s++;
        t++;
        n--;
      }
    }
    return 0;
  }
  else
#endif /* KANJI_WIN95_COMPATIBILITY */
  {
    while (n && *s && *t && toupper(*s) == toupper(*t))
    {
      s++;
      t++;
      n--;
    }

    /* not run out of chars - strings are different lengths */
    if (n) 
      return(toupper(*s) - toupper(*t));

    /* identical up to where we run out of chars, 
       and strings are same length */
    return(0);
  }
}
コード例 #11
0
ファイル: kanji.c プロジェクト: MidnightCommander/mc
static BOOL
is_kanji_multibyte_char_1 (char c)
{
    return is_shift_jis (c);
}