Ejemplo n.º 1
0
int main()
{
	int i;
	char temp;
	scanf("%s",word1);
	scanf("%s",word2);
	memset(stat1,'\0',sizeof(stat1));
	memset(stat2,'\0',sizeof(stat2));
	for(i=0;word1[i];i++){
		temp=UPCASE(word1[i]);
		stat1[temp-'A']++;
	}
	for(i=0;word2[i];i++){
		temp=UPCASE(word2[i]);
		stat2[temp-'A']++;
	}
	for(i=0;i<26;i++){
		if(stat2[i]!=stat1[i]){
			printf("N\n");
			break;
		}
	}
	if(i==26)
		printf("Y\n");
	return 0;
}
Ejemplo n.º 2
0
/* The actual soundex routine */
static char *
soundex(char *str)
{
  static char tbuf1[BUFFER_LEN];
  char *p;

  memset(tbuf1, '\0', 4);

  p = tbuf1;

  /* First character is just copied */
  *p = UPCASE(*str);
  str++;
  /* Special case for PH->F */
  if ((UPCASE(*p) == 'P') && *str && (UPCASE(*str) == 'H')) {
    *p = 'F';
    str++;
  }
  p++;
  /* Convert letters to soundex values, squash duplicates, skip accents and other non-ascii characters */
  while (*str) {
    if (!isalpha(*str) || *str > 127) {
      str++;
      continue;
    }
    *p = soundex_val[*str++];
    if (*p != *(p - 1))
      p++;
  }
  *p = '\0';
  /* Remove zeros */
  p = str = tbuf1;
  while (*str) {
    if (*str != '0')
      *p++ = *str;
    str++;
  }
  *p = '\0';
  /* Pad/truncate to 4 chars */
  if (tbuf1[1] == '\0')
    tbuf1[1] = '0';
  if (tbuf1[2] == '\0')
    tbuf1[2] = '0';
  if (tbuf1[3] == '\0')
    tbuf1[3] = '0';
  tbuf1[4] = '\0';
  return tbuf1;
}
Ejemplo n.º 3
0
std::string auxiliary::mirror(const std::string& a, const char& c)
{
    static const String facets="FURBDL";
    static String Plane[3];
    Plane['X'-'X']="RL";
    Plane['Y'-'X']="UD";
    Plane['Z'-'X']="FB";
    bool cuttingSide[6];
    for(int i=0;i<6;++i)
    {
        cuttingSide[i]=(Plane[c-'X'].find(facets[i])==String::npos);
    }
    String Result;
    for(String::const_iterator it=a.begin();it!=a.end();++it)
    {
        String add, side;
	const int low_case=IS_LOWCASE(*it);
        const int pos= facets.find(UPCASE(*it));
        const char I = *it;
        if(cuttingSide[pos])
        {
            side.push_back(I);
        }
        else
        {
            side=facets[(pos+3)%6]; /* opposite side */
        }
        side[0]|=low_case;
        if(it+1!=a.end())
        {
            switch(*(it+1))
            {
            case '\'':
                add=side;
                ++it;
                break;

            case '|':
                add.push_back(I);
                add.push_back('|');
                ++it;
                break;

            case '2':
                add=side+"2";
                ++it;
                break;

            default:
                add=side+"'";
            }
        }
        else
        {
            add=side+"'";
        }
        Result+=add;
    }
    return Result;
}
Ejemplo n.º 4
0
/*
===============================================================================
函数
Full Path converts To Sector,SectorOffset,Cluster
入口:u8 *filename
出口:SUCC,FAIL(u32 *cluster_no,u32 *sector,u16 *offset)
===============================================================================
*/
static u8 FullPathToSectorCluster(u8 *filename1)
{
   u8 buf[280];
   u8 *filename;
   filename = buf;
   stringcpy(filename1,filename);
   UPCASE(filename);
     if( ((* filename) >= 'C' && ( * filename ) <= 'Z')||
		((* filename) >= 'c' && ( * filename ) <= 'z') )  //从指定盘符根目录开始寻址
       {
         if(( * (filename + 1)) == ':')
          {                          
           if( *( filename + 2 ) == '\\')
            { 
              if(LengthofString(filename) > Maximum_File_Path_Name)
			      return(EpathLengthsOVERFLOW);
              if(Read_partition_PBP((u8)((*filename) - 'C')) != SUCC)
                 return(FAIL);
              filename += 3; 
              CORE.SectorNum = CORE.FirstRootDirSecNum; 
              CORE.DirectoryType =  RootDirectory;
              CORE.offset = 0;   
             }
          }
         else 
          {   
             if((LengthofString(filename) + LengthofString(CORE.current_folder)) > Maximum_File_Path_Name)
                   return(EpathLengthsOVERFLOW);
             if(CORE.CurrentDirectoryType ==  RootDirectory)
			 {
			    CORE.SectorNum = CORE.FirstRootDirSecNum;
			 }  
             else
              {
                 CORE.ClusterNum = CORE.ClusterNOofCurrentFolder;
                 CORE.SectorNum = FirstSectorofCluster(CORE.ClusterNum); 
              }
             CORE.DirectoryType = CORE.CurrentDirectoryType;
             CORE.offset = 0;	 
          }  
       }
     else if((* filename) == '\\')
            {
             if((LengthofString(filename) + 1) > Maximum_File_Path_Name)
                   return(EpathLengthsOVERFLOW); 

             filename ++;    //从当前盘符,根目录开始寻址
             CORE.SectorNum = CORE.FirstRootDirSecNum; 
             CORE.DirectoryType = RootDirectory;
             CORE.offset = 0;
            }   
  if(*filename)
  return(RelativePathToSectorCluster(filename));
  else
	return(SUCC);
   
}
Ejemplo n.º 5
0
char GetName()
{
    char c = Look;

    if( !IsAlpha(Look)) {
        sprintf(tmp, "Name");
        Expected(tmp);
    }

    GetChar();

    return UPCASE(c);
}
Ejemplo n.º 6
0
/*
===============================================================================
函数
字符串比较(不区分大小写)
入口:*string1:字符串1首地址;*string2:字符串2首地址
出口:SUCC,FAIL
===============================================================================
*/ 
static u8 stringcmp(u8 *string1,u8 *string2)
{
 UPCASE(string1);
 UPCASE(string2);  
 while((*string1) && (*string2)) 
   {
     if((*string1) == (*string2))
      {
         string1++;
         string2++;
      }
     else
       return(FAIL);
   }   
   
 if( ((*string1) == 0) && ((*string2) == 0))
 {
     return(SUCC);
 }
 else
     return(FAIL);
}
Ejemplo n.º 7
0
void GetToken()
{
    char temp[4];
    int length = 0;

    char ch = fgetc(fp);
    while(  ch != EOF   && ch != '\0' && 
            ch != (char)0x20  && ch != '\n' &&
            length < 4)
    {
        temp[length] = ch;
        ch = fgetc(fp);
        length++;
    }

    char *string = malloc(length * sizeof(char));
   
    /* 
     * Checks if string is actually a number
     */
    int isNumber = 1;
    int i;
    for(i = 0;i<length;i++)
    {
        if(temp[i] <= 47 ||
            temp[i] >= 58)
            isNumber = 0;
    }

    //Assumes number is in base 10
    if(isNumber == 0)
    {
        for(i = 0;i< length;i++)
            string[i] = UPCASE(temp[i]);
        
        Look->value.string = string;
        Look->strLength = length;
    }
    else
    {
        int tempNum = 0;
        for(i = 0;i<length;i++)
            tempNum = tempNum * 10 + temp[i] - 48;

        Look->value.number = tempNum;
        Look->strLength = 0;
    }
}
Ejemplo n.º 8
0
char *  GetName() {
  if(!IsAlpha(Look)) {
      Expected("Name");
  }
  char* Token = malloc(100 * sizeof *Token);
  Token[0] = '\0';
  int i = 0;
  while(IsAlNum(Look)) {
    Token[i] = UPCASE(Look);
    GetChar();
    i++;
  }
  Token[i] = '\0';
  SkipWhite();
  return Token;
}
Ejemplo n.º 9
0
static Lisp_Object
casify_object (enum case_action flag, Lisp_Object string_or_char,
	       Lisp_Object buffer)
{
  struct buffer *buf = decode_buffer (buffer, 0);

 retry:

  if (CHAR_OR_CHAR_INTP (string_or_char))
    {
      Ichar c;
      CHECK_CHAR_COERCE_INT (string_or_char);
      c = XCHAR (string_or_char);
      if (flag == CASE_DOWN)
	{
	  c = DOWNCASE (buf, c);
	}
      else if (flag == CASE_UP)
	{
	  c = UPCASE (buf, c);
	}
      else
	{
	  c = CANONCASE (buf, c);
	}

      return make_char (c);
    }

  if (STRINGP (string_or_char))
    {
      Lisp_Object syntax_table = buf->mirror_syntax_table;
      Ibyte *storage =
	alloca_ibytes (XSTRING_LENGTH (string_or_char) * MAX_ICHAR_LEN);
      Ibyte *newp = storage;
      Ibyte *oldp = XSTRING_DATA (string_or_char);
      Ibyte *endp = oldp + XSTRING_LENGTH (string_or_char);
      int wordp = 0, wordp_prev;

      while (oldp < endp)
	{
	  Ichar c = itext_ichar (oldp);
	  switch (flag)
	    {
	    case CASE_UP:
	      c = UPCASE (buf, c);
	      break;
	    case CASE_DOWN:
	      c = DOWNCASE (buf, c);
	      break;
	    case CASE_CANONICALIZE:
	      c = CANONCASE (buf, c);
	      break;
	    case CASE_CAPITALIZE:
	    case CASE_CAPITALIZE_UP:
	      wordp_prev = wordp;
	      wordp = WORD_SYNTAX_P (syntax_table, c);
	      if (!wordp) break;
	      if (wordp_prev)
		{
		  if (flag == CASE_CAPITALIZE)
		    c = DOWNCASE (buf, c);
		}
	      else
		c = UPCASE (buf, c);
	      break;
	    }

	  newp += set_itext_ichar (newp, c);
	  INC_IBYTEPTR (oldp);
	}

      return make_string (storage, newp - storage);
    }

  string_or_char = wrong_type_argument (Qchar_or_string_p, string_or_char);
  goto retry;
}
Ejemplo n.º 10
0
void
init_editfns ()
{
  char *user_name;
  register unsigned char *p, *q;
  struct passwd *pw;		/* password entry for the current user */
  Lisp_Object tem;
  extern char *index ();

  /* Turn off polling so the SIGALRM won't bother getpwuid.  */
  stop_polling ();

  /* Set up system_name even when dumping.  */

  Vsystem_name = build_string (get_system_name ());
  p = XSTRING (Vsystem_name)->data;
  while (*p)
    {
      if (*p == ' ' || *p == '\t')
	*p = '-';
      p++;
    }

#ifndef CANNOT_DUMP
  /* Don't bother with this on initial start when just dumping out */
  if (!initialized)
    return;
#endif				/* not CANNOT_DUMP */

  pw = (struct passwd *) getpwuid (getuid ());
#ifndef OS2
  Vuser_real_name = build_string (pw ? pw->pw_name : "unknown");
#endif

  /* Get the effective user name, by consulting environment variables,
     or the effective uid if those are unset.  */
  user_name = (char *) getenv ("USER");
  if (!user_name)
    user_name = (char *) getenv ("LOGNAME"); /* USG equivalent */
  if (!user_name)
    {
      pw = (struct passwd *) getpwuid (geteuid ());
      user_name = pw ? pw->pw_name : "unknown";
    }
  Vuser_name = build_string (user_name);
#ifdef OS2
  Vuser_real_name = build_string (user_name);
#endif

  /* If the user name claimed in the environment vars differs from
     the real uid, use the claimed name to find the full name.  */
  tem = Fstring_equal (Vuser_name, Vuser_real_name);
  if (NULL (tem))
    pw = (struct passwd *) getpwnam (XSTRING (Vuser_name)->data);

  p = (unsigned char *) getenv("USERFULLNAME");
  if (p==0)
    p = (unsigned char *) (pw ? USER_FULL_NAME : "unknown");
  q = (unsigned char *) index (p, ',');
  Vuser_full_name = make_string (p, q ? q - p : strlen (p));

#ifdef AMPERSAND_FULL_NAME
  p = XSTRING (Vuser_full_name)->data;
  q = (unsigned char *) index (p, '&');
  /* Substitute the login name for the &, upcasing the first character.  */
  if (q)
    {
      char *r
	= (char *) alloca (strlen (p) + XSTRING (Vuser_name)->size + 1);
      bcopy (p, r, q - p);
      r[q - p] = 0;
      strcat (r, XSTRING (Vuser_real_name)->data);
      r[q - p] = UPCASE (r[q - p]);
      strcat (r, q + 1);
      Vuser_full_name = build_string (r);
    }
#endif				/* AMPERSAND_FULL_NAME */

  start_polling ();
}
Ejemplo n.º 11
0
static Lisp_Object
casify_object(enum case_action flag, Lisp_Object string_or_char,
	      Lisp_Object buffer)
{
	struct buffer *buf = decode_buffer(buffer, 0);

      retry:

	if (CHAR_OR_CHAR_INTP(string_or_char)) {
		Emchar c;
		CHECK_CHAR_COERCE_INT(string_or_char);
		c = XCHAR(string_or_char);
		c = (flag == CASE_DOWN) ? DOWNCASE(buf, c) : UPCASE(buf, c);
		return make_char(c);
	}

	if (STRINGP(string_or_char)) {
		Lisp_Char_Table *syntax_table =
		    XCHAR_TABLE(buf->mirror_syntax_table);
		Bufbyte *storage =
		    alloca_array(Bufbyte,
				 XSTRING_LENGTH(string_or_char) *
				 MAX_EMCHAR_LEN);
		Bufbyte *newp = storage;
		Bufbyte *oldp = XSTRING_DATA(string_or_char);
		int wordp = 0, wordp_prev;

		while (*oldp) {
			Emchar c = charptr_emchar(oldp);
			switch (flag) {
			case CASE_UP:
				c = UPCASE(buf, c);
				break;
			case CASE_DOWN:
				c = DOWNCASE(buf, c);
				break;
			case CASE_CAPITALIZE:
			case CASE_CAPITALIZE_UP:
				wordp_prev = wordp;
				wordp = WORD_SYNTAX_P(syntax_table, c);
				if (!wordp)
					break;
				if (wordp_prev) {
					if (flag == CASE_CAPITALIZE)
						c = DOWNCASE(buf, c);
				} else
					c = UPCASE(buf, c);
				break;

				/* can't happen */
			default:
				/* abort()? */
				break;
			}

			newp += set_charptr_emchar(newp, c);
			INC_CHARPTR(oldp);
		}

		return make_string(storage, newp - storage);
	}

	string_or_char = wrong_type_argument(Qchar_or_string_p, string_or_char);
	goto retry;
}
Ejemplo n.º 12
0
void
init_editfns ()
{
  char *user_name;
  register unsigned char *p, *q;
  struct passwd *pw;		/* password entry for the current user */
  Lisp_Object tem;
  extern char *index ();

  /* Set up system_name even when dumping.  */

  Vsystem_name = build_string (get_system_name ());
  p = XSTRING (Vsystem_name)->data;
  while (*p)
    {
      if (*p == ' ' || *p == '\t')
	*p = '-';
      p++;
    }

#ifndef CANNOT_DUMP
  /* Don't bother with this on initial start when just dumping out */
  if (!initialized)
    return;
#endif				/* not CANNOT_DUMP */

  pw = (struct passwd *) getpwuid (getuid ());
  Vuser_real_name = build_string (pw ? pw->pw_name : "unknown");

  user_name = (char *) getenv ("USER");
  if (!user_name)
    user_name = (char *) getenv ("LOGNAME"); /* USG equivalent */
  if (user_name)
    Vuser_name = build_string (user_name);
  else
    Vuser_name = Vuser_real_name;

  tem = Fstring_equal (Vuser_name, Vuser_real_name);
  if (!NULL (tem))
    pw = (struct passwd *) getpwnam (user_name);
  
  p = (unsigned char *) (pw ? USER_FULL_NAME : "unknown");
  q = (unsigned char *) index (p, ',');
  Vuser_full_name = make_string (p, q ? q - p : strlen (p));

#ifdef AMPERSAND_FULL_NAME
  p = XSTRING (Vuser_full_name)->data;
  q = (unsigned char *) index (p, '&');
  /* Substitute the login name for the &, upcasing the first character.  */
  if (q)
    {
      char *r
	= (char *) alloca (strlen (p) + XSTRING (Vuser_name)->size + 1);
      bcopy (p, r, q - p);
      r[q - p] = 0;
      strcat (r, XSTRING (Vuser_real_name)->data);
      r[q - p] = UPCASE (r[q - p]);
      strcat (r, q + 1);
      Vuser_full_name = build_string (r);
    }
#endif				/* AMPERSAND_FULL_NAME */
}
Ejemplo n.º 13
0
int IsAlpha(char x) {
  return (UPCASE(x) >= 'A' && UPCASE(x) <= 'Z');
}
Ejemplo n.º 14
-1
int IsAlpha(char c)
{
    return (UPCASE(c) >= 'A') && (UPCASE(c) <= 'Z');
}