Exemplo n.º 1
0
// reads an instruction line from the input file
// lines consisting solely of whitespace and/or comments are skipped
char* get_line(FILE* in , char* buffer)
{
	if(fgets(buffer,LINE_BUFFER_SIZE,in) == NULL) return NULL;
	char* line = make_lower(trim(trim_comment(buffer)));
	if(streq(line,"")) return get_line(in,buffer);
	else return line;
}
Exemplo n.º 2
0
/**
 * Funkcja, która finalizuje wczytywanie słowa i wypisuje o nim informacje.
 * Na standardowe wyjście słowo zostaje przepisane, lub przepisane poprzedzone
 * znakiem '#', jeśli go nie znaleziono w słowniku.
 * Jeśli w 'pstate' ustawiony jest tryb "verbose", wypisywane są również
 * dodatkowe informacje o podpowiedziach na wyjście błędów.
 * @param [in,out] pstate Stan parsera. Zostanie uaktualniona jedynie pozycja
 * w buforze.
 */
void process_word(struct parser_state * pstate)
{
    // finalizing buffer iterator
    *pstate->buffer_iterator = L'\0';
    pstate->buffer_iterator = word_buffer;

    // word for dictionary
    make_lower(word_buffer, word_buffer_lowered);

    // true position of the word
    int word_column_num = pstate->last_non_word_column_num + 1;

    // getting data from dictionary and printing it
    const bool is_in_dict = dictionary_find(pstate->dict, word_buffer_lowered);
    if (!is_in_dict && pstate->verbose)
    {
        {
            struct word_list wlist;
            dictionary_hints(pstate->dict, word_buffer_lowered, &wlist);
            print_verbose_info(pstate, word_column_num, &wlist, stderr);
        }
        fputwc(L'#', stdout);
    }
    fputws(word_buffer, stdout);
}
Exemplo n.º 3
0
inline S to_lower(S const& s)
{
    S   r(s);

    make_lower(r);

    return r;
}
Exemplo n.º 4
0
/*ARGSUSED*/
static int
configd_thread(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
{
	thread_info_t t;
	char state[20];
	char oldstate[20];

	if (!(flags & DCMD_ADDRSPEC)) {
		if (mdb_walk_dcmd("configd_threads", "configd_thread", argc,
		    argv) == -1) {
			mdb_warn("can't walk 'configd_threads'");
			return (DCMD_ERR);
		}
		return (DCMD_OK);
	}

	if (argc != 0)
		return (DCMD_USAGE);

	if (DCMD_HDRSPEC(flags)) {
		mdb_printf("%<u>%-?s %5s %-12s %-12s %-?s %-?s %-?s%</u>\n",
		    "ADDR", "TID", "STATE", "PREV_STATE", "CLIENT", "CLIENTRQ",
		    "MAINREQ");
	}

	if (mdb_vread(&t, sizeof (t), addr) == -1) {
		mdb_warn("failed to read thread_info_t at %p", addr);
		return (DCMD_ERR);
	}

	enum_lookup(state, sizeof (state), thread_state_enum,
	    t.ti_state, "TI_", "");
	make_lower(state, sizeof (state));

	enum_lookup(oldstate, sizeof (oldstate), thread_state_enum,
	    t.ti_prev_state, "TI_", "");
	make_lower(oldstate, sizeof (oldstate));

	mdb_printf("%0?p %5d %-12s %-12s %?p %?p %?p\n",
	    (void *)addr, t.ti_thread, state, oldstate,
	    t.ti_active_client, t.ti_client_request, t.ti_main_door_request);

	return (DCMD_OK);
}
Exemplo n.º 5
0
BOOL CSoftInfoQuery::Initialize(LPCWSTR pKSafePath)
{
	assert(pKSafePath != NULL && _pNotify != NULL);

	_ksafePath = pKSafePath; 
	trim_right(_ksafePath, L"\\"); 
	make_lower(_ksafePath);

	return InitCacheDB();
}
Exemplo n.º 6
0
bool CVectorFileSystemVisitor::VisitFile(const char* fullFilePath, const char* fileName)
{
    m_vec.push_back(behaviac::string());
    behaviac::string& str = m_vec.back();
    str = m_storeFullPath ? fullFilePath : fileName;

    if (!m_keepCase)
    {
        str = make_lower(str);
    }

    return m_maximumSize == 0 || m_vec.size() < m_maximumSize;
}
Exemplo n.º 7
0
END_TEST


START_TEST(test_make_lower)
{
    char strs[][4][20] = {{ "oNe", "TWO", "three", "Four" },
    { "ALPHA", "beta", "Gamma", "Theta" }};
    char ref[][4][20] = {{ "one", "two", "three", "four" },
    { "alpha", "beta", "gamma", "theta" }};

    const unsigned int num = 4;
    
    for (int k = 0; k < 2; k++) {
    char **arr = init_array();
    if(!arr) {
      fail("[Task 4.3.c] init_array returned NULL");
    }
    for (unsigned int i = 0; i < num; i++) {
        char **a2 = add_string(arr, strs[k][i]);
	if (!a2) {
	  free_strings(arr);
	  fail("[Task 4.3.c] add_string returned NULL");
	}
	arr = a2;
    }
    
    char buf[200];
    printref(buf, strs[k], num);
    
    make_lower(arr);
    
    for (unsigned int i = 0; i < num; i++) {
        if (strcmp(arr[i], ref[k][i])) {
            remove_nonascii(arr[i]);
            char buf2[200];
            sprintf(buf2, "[Task 4.3.c] After adding strings {%s}, array member %d is '%s', should be '%s'",
                    buf, i, arr[i], ref[k][i]);
            free_strings(arr);
            fail(buf2);
        }
    }
    free_strings(arr);
    }
}
Exemplo n.º 8
0
BOOL CSoftUninstall::Initialize(LPCWSTR pKSafePath)
{
	assert(pKSafePath != NULL && _pNotify != NULL);

	_ksafePath = pKSafePath; 
	trim_right(_ksafePath, L"\\"); 
	make_lower(_ksafePath);

	if(
		!filesystem_traits<wchar_t>::file_exists((_ksafePath + SOFT_UNINST_DAT).c_str()) ||
		!filesystem_traits<wchar_t>::file_exists((_ksafePath + SOFT_PINYIN_DAT).c_str()) ||
		!InitCacheDB() ||
		!_commTaskMgr.Startup()
		) 
		return FALSE;

	// 启动初始化任务
	return StartTask(new CSoftInitTask(this));
}
Exemplo n.º 9
0
CPathID::CPathID(const char* path, bool doNotFromat)
{
    BEHAVIAC_ASSERT(path);

    if (doNotFromat)
    {
        behaviac::string strPath(path);
        strPath = make_lower(strPath);
        SetContentPrivate(strPath.c_str());
#ifdef BEHAVIAC_ENABLE_ASSERTS
        CPathID pathId(path);
        BEHAVIAC_ASSERT(GetUniqueID() == pathId.GetUniqueID());
#endif // #ifdef BEHAVIAC_ENABLE_ASSERTS
    }
    else
    {
        SetContent(path);
    }
}
Exemplo n.º 10
0
    //! @brief Destroys the node.
    //!
    //! Deletes its children recursively. Clears the pointers if they are case
    //! sensitive.
    ~trie_node(void) noexcept(true)
    {
        // release all children first
        for (size_t i = 0; i < children_.size(); i++) {
            const uint8_t c = static_cast<uint8_t>(i);
            trie_node* child = children_[c];

            // delete only if set
            if (child != NULL) {
                delete child;

                // when the corresponding lower case points to the same data,
                // just clear it, because it got already deleted
                if (check_range<uint8_t, 'A', 'Z'>(c)) {
                    trie_node*& other = children_[make_lower(c)];
                    clear_right_side_when_equal(child, other);
                }
            }
        }
    }
Exemplo n.º 11
0
/**
 * @brief Function <b>lower</b> returns a lower case version of the string.
 *
 * @param s		a <b>String</b> const reference to be lower cased.
 *
 * @return		a <b>String</b> value of the lower cased string.
 */
inline String lower(const String &s)
{
  String t = s;
  return make_lower(t);
}
Exemplo n.º 12
0
main() {
   int x, y, loop = 1, fact = 0;
   char instring[200], outstring[200], sub[200], vrb[200], rst[200], qwd[200];
   char osub[200], ovrb[200], orst[200];
   fam = 0;
   printf("Hello there.  My name is Eliza and I was written by Mohan Embar.\n");
   printf("Please type \"END\" to end this session.\n");
   printf("I'm here to help you if I can.  What seems to be the trouble?\n");
   while (loop) {
      printf("\n");
      gets(instring);
      printf("\n");
      parse(instring);
      if (numwords == 0) {
         switch (x = randnum(2)) {
            case 1 : printf("Don't you have anything to say?\n");
               break;
            case 2 : printf("Cat got your tongue?\n");
               break;
         }
         continue;
      }
      if (!strcmp(s[1],"END")) {
         printf("Goodbye.  Please come again.\n");
         break;
      }
      agree();
      if (bad_word())
         printf(b_word_resp());
      else if (naughty_word())
         printf(n_word_resp());
      else if (x = family()) {
         fam = x;
         printf(fam_resp());
         strcpy(fam_member,s[fam]);
      }
      else if (sword("ALIKE",1))
         printf(alike_resp());
      else if (sword("ALWAYS",1))
         printf(always_resp());
      else if (sword("BECAUSE",1))
         printf(because_resp());
      else if (sword("YES",1))
         printf(yes_resp());
      else if (sword("NO",1) || sword("NOT",1))
         printf(neg_resp());
      else if (x = i_am()) { /* If occurrence of I AM x.. */
         get_til_stop(x,outstring);    /* Get I AM x .. into outstring */
         printf(i_am_resp(),outstring); /* Print reponse for this */
      }
      else if (real_quest() ||
              (is_helper(s[1]) && is_sub_pronoun(s[2])) ||
              sub_and_helper()) {
         if (real_quest()) {
            strcpy(qwd,s[1]);
            strcpy(vrb,s[2]);
            strcpy(sub,s[3]);
            get_til_stop(4,rst);
         }
         else if (is_helper(s[1]) && is_sub_pronoun(s[2])) {
            strcpy(vrb,s[1]);
            strcpy(sub,s[2]);
            get_til_stop(3,rst);
            strcpy(qwd,"YES");
         }
         else if (sub_and_helper()) {
            x = find_helper();
            y = search_back_sub(x);
            strcpy(vrb,s[x]);
            get_til_stop(x+1,rst);
            getrange(y,x-1,sub);
            strcpy(qwd,"NO");
         }
         make_lower(qwd);
         if (strcmp(sub,"I")) make_lower(sub);
         make_lower(vrb);
         make_lower(rst);
         /* First do x verb y responses */

         /*
	 printf("\n*** %s\n",sub);
         */
	 
	 if (!strcmp(sub," I") || !strcmp(sub,"I")) {
            printf(you_resp());
         }
         else if (!strcmp(qwd,"no")) {
            /* Record this statement for later use. */
            fact = 1;
            strcpy(osub,sub); strcpy(ovrb,vrb); strcpy(orst,rst);
            if (is_be(vrb) && !strcmp(sub," you") && (y = sad_word())) {
               getrange(y,y,outstring);
               x = randnum(5)+6;
            }
            else if (is_be(vrb) && (y = sad_word())) {
               getrange(y,y,outstring);
               x = randnum(2)+11;
            }
            else if (is_be(vrb))
               x = randnum(6);
            else x = randnum(4);
            switch (x) {
               case 1 : printf("How do you feel about%s?\n",cnnv(sub));
                  break;
               case 2 : printf("Why %s%s%s?\n",vrb,sub,rst);
                  break;
               case 3 : for (y=1;sub[y]=sub[y--];y=y+2);
                  sub[0] = toupper(sub[0]);
                  printf("%s %s%s?\n",sub,vrb,rst);
                  break;
               case 4 : printf("Could you describe%s for me?\n",cnnv(sub));
                  break;
               case 5 : printf("What if%s were not%s?\n",sub,rst);
                  break;
               case 6 : printf("Would you be happy if%s were not%s?\n",sub,
                                rst);
                  break;
               case 7 : printf("I'm sorry to hear that you are%s.\n",outstring);
                  break;
               case 8 : printf("Do you think that coming here will help you not to be%s?\n",outstring);
                  break;
               case 9 : printf("Let's talk about why you feel%s.\n",outstring);
                  break;
               case 10 : printf("What happened that made you feel%s?\n",outstring);
                  break;
               case 11 : printf("What could be the reason for your feeling%s?\n",outstring);
                  break;
               case 12 : printf("What could cause%s to be%s?\n",cnnv(sub),outstring);
                  break;
               case 13 : printf("If%s came here, would it help%s not to be%s?\n",sub,cnnv(sub),outstring);
                  break;
            }
         }
         else if (!strcmp(sub,"you"))
            printf(you_know());
         else if (!strcmp(qwd,"yes")) {
            x = randnum(8);
            switch (x) {
               case 1 : printf("You want to know if %s %s%s.\n",sub,vrb,rst);
                  break;
               case 2 : printf("If %s %s%s, does that concern you?\n",sub,vrb,rst);
                  break;
               case 3 : printf("What are the consequences if %s %s%s?\n",sub,vrb,rst);
                  break;
               case 4 : printf("Why does %s concern you?\n",sub);
                  break;
               case 5 : printf("Why are you thinking of %s?\n",cnnv(sub));
                  break;
               case 6 : printf("Tell me more about %s.\n",cnnv(sub));
                  break;
               case 7 : printf("To answer that, I'd need to know more about %s.\n",cnnv(sub));
                  break;
               case 8 : printf("What is the relationship between you and %s?\n",cnnv(sub));
                  break;
               case 9 : printf("Why don't you ask %s?\n",cnnv(sub));
                  break;
            }
         }
         else {
            x = randnum(8);
            switch (x) {
               case 1 : printf("You want to know %s %s %s%s.\n",qwd,sub,vrb,rst);
                  break;
               case 2 : printf("If %s %s%s, does that concern you?\n",sub,vrb,rst);
                  break;
               case 3 : printf("What are the consequences if %s %s%s?\n",sub,vrb,rst);
                  break;
               case 4 : printf("Why does %s concern you?\n",sub);
                  break;
               case 5 : printf("Why are you thinking of %s?\n",cnnv(sub));
                  break;
               case 6 : printf("Tell me more about %s.\n",cnnv(sub));
                  break;
               case 7 : printf("To answer that, I'd need to know more about %s.\n",cnnv(sub));
                  break;
               case 8 : printf("What is the relationship between you and %s?\n",cnnv(sub));
                  break;
               case 9 : printf("Why don't you ask %s?\n",cnnv(sub));
                  break;
            }
         }
      }
      else if (is_command())
         printf(command_resp());
      else if (vague_quest())
         printf(question());
      else if ((s[numwords][0] == '?') && !real_quest())
         printf(question());
      else if (x = sad_word()) {
         getrange(x,x,outstring);
         for (y=1;outstring[y]=outstring[y--];y=y+2);
         outstring[0] = toupper(outstring[0]);
         printf("%s?\n",outstring);
      }
      else if (x = can_spit_out()) {
         if (x<=(numwords-2) && is_sub_pronoun(s[x])
                             && (matches("NEED",s[x+1]) ||
                                 matches("WANT",s[x+1]))) {
            get_til_stop(x+2,outstring);
            strcpy(sub,s[x]);
            if (strcmp(sub,"I")) make_lower(sub);
            if (strcmp(s[x],"I")) make_lower(s[x]);
            x = randnum(6);
            switch (x) {
               case 1 : printf("What would it mean to %s if %s got%s?\n",cnnv2(s[x]),sub,outstring);
                  break;
               case 2 : printf("Would %s really be happy if %s got%s?\n",sub,sub,outstring);
                  break;
               case 3 : printf("Why is getting%s so desirable?\n",outstring);
                  break;
               case 4 : printf("Okay.  Suppose %s got%s.  Then what?\n",sub,outstring);
                  break;
               case 5 : printf("Why is this important to %s?\n",cnnv2(sub));
                  break;
               case 6 : printf("What price would %s pay to achieve this?\n",sub);
                  break;
            }
         }
         else {
            get_til_stop(x,outstring);
            outstring[1]=toupper(outstring[1]);
            printf("%s.\n",outstring+1);
         }
      }
      else if (fam) {
         make_lower(fam_member);
         printf(family_resp(),fam_member);
         fam = 0;
      }
      else if (fact && (randnum(5)==3)) {
         printf(old_fact(),osub,ovrb,orst);
         fact = 0;
      }
      else {
         printf(go_on());
      }
   }
}