// #include // #include // #include #include // #include // #include // #include #include "getch.h" #include "word.h" // #define MAXBUFF 100 // // uint32_t top; // char *wstack[MAXBUFF]; char getword(char *word, int lim) { char *w = word; // if (top > 0) // return *wstack[--top]; while (isblank(*w = getch())) ; if (isalpha(*w)) { while ((isalnum(*++w = getch()) || *w == '_') && --lim > 0) ; ungetch(*w--); } else if (*w == '#') { --lim; do { *++w = getch(); } while (isalpha(*w) && --lim > 0); ungetch(*w--); } *++w = '\0'; return word[0]; } // // void ungetword(char *word) // { // if (top < MAXBUFF) { // if ((wstack[top++] = strdup(word)) == NULL) // error(EXIT_FAILURE, ENOBUFS, "ungetword"); // } else { // error(EXIT_FAILURE, ENOBUFS, "ungetword"); // } // } // // void wordfree(void) // { // uint32_t i; // // for (i = 0; i < top; ++i) // free(wstack[i]); // }