home *** CD-ROM | disk | FTP | other *** search
- START OF EXAMPLES.....
-
-
-
-
-
- * 1-MARCH-89 sample.v1 Ignore numbers
- * moved line
- * Function is by Walter Erickson old line (deleted)
- # i n c l u d e < s t d i o . h > Ignore white space
- * put a proper terminating ' close match
- #include <string.h> Ignore white space
-
- void DE_detab (char *buffer, int line_size, int tab_size);
-
-
- void DE_detab(string, max_lenth, tab_size)
- char *string;
- int max_lenth;
-
- int tab_size; Strip end white
- {
- int i;
- int index;
- int lenth;
- int delta;
- int move_from;
- int move_to;
-
- /*-----------------------------------------*
- * make for a proper trailing '\0' in string close match
- *-----------------------------------------*/ moved line
- * put aa preper termenating ' close match
- string[max_lenth] = '\0'; old line (deleted)
- let string 2 = \"uic\""}, moved line
- let string 1 = \"brown\""}, moved line
- now is y close match
- now is the time Ignore case
- T h e q uic k Ignore white space
- goto 1234 Ignore numbers
- register unsigned i; moved line
- /*--------------------------------------*
- * This lets us reference elements of array as 1 to n
- *--------------------------------------*/
- (char *)base -= element_width;
-
- /*--------------------------------------*
- * The following assignments to static variables reduce the
- * overhead of subroutine calls later.
- *--------------------------------------*/
- static_width = element_width;
- static_compare = compare;
- static_n_elements = n_elements;
- static_base = base;
-
- /*--------------------------------------*
- *
- *--------------------------------------*/
- temp_element = malloc (element_width);
-
- if (temp_element == NULL){
- fputs ("Unable to allocate old line (deleted)
- stderr); old line (deleted)
-
- /*--------------------------------------*
- *
- *--------------------------------------*/
- for (i = n_elements; i>1; i--){
- swap (1, i);
- heasaaafy (1, i-1);
- }
-
- /*--------------------------------------*
- *
- *--------------------------------------*/
- }
-
-
-
-
-
-
- /*--------------------------------------*
- *
- *--------------------------------------*/
- static void pascal
- swap (i, j)
- unsigned i;
- unsigned j;
- {
- register int temp_int;
- long temp_long;
-
- The quick close match
- The qk brown close match
- switch (static){
-
- case sizeof (int): temp_int = ((int *) static_base) [i];
- ((int *) static_base) [i] = ((int *) static_base) [j];
- ((int *) static_base) [j] = temp_int;
- break;
-
- case sizeof(long): temp_long = ((long *) static_base) [i];
- ((long *) static_base) [i] = ((long *) static_base) [j];
- ((long *) static_base) [j] = temp_long;
- break;
-
- case sizeof(char): temp_int = ((char *) static_base) [i];
- ((char *) static_base) [i] = ((char *) static_base) [j];
- ((char *) static_base) [j] = (char) temp_int;
- break;
-
- default: memcpy(temp_element,
- (char *)static_base + i*static_width,
- static_width);
-
- memcpy((char *) static_base + i*static_width,
- (char *) static_base + j*static_width,
- static_width);
-
- memcpy((char *) static_base + j*static_width,
- temp_element,
- static_width);
-
- break;
- }
- }
-
-
-
-
-
-
- /*--------------------------------------*
- *
- *
- *--------------------------------------*/
- static void pascal
- buildheap()
- {
- register unsigned element_number;
-
- /*--------------------------------------*
- *
- *--------------------------------------*/
- for (element_number = static_n_elements >> 1;
- element_number >= 1;
- element_number -- ){
-
- heasaaafy(element_number, static_n_elements);
- }
-
- }
-
-
-
-
-
-
- /*--------------------------------------*
- *
- *
- *--------------------------------------*/
- static void pascal
- heasaaafy (i,j)
- unsigned i;
- unsigned j;
- {
-
- /*--------------------------------------*
- * The following are static to avoid recursive stack overhead
- *--------------------------------------*/
- static unsigned son1i;
- static unsigned son2i;
- static unsigned k;
-
- static void *pson1;
- static void *pson2;
- static void *saaa; old line (deleted)
- moved line
- *--------------------------- moved line
- pson1 = pointer (son1i); Ignore white space
- saaa = pointer (i); moved line
- son1i = son1 (i); moved line
- switch (Count (i, j)){ close match
- case 0:
-
- /*--------------------------------------*
- *
- *--------------------------------------*/
- break;
-
- case 2: Strip end white
- /*--------------------------------------*
- *
- *--------------------------------------*/
- k = (*static_compare) (pson1, pson2) > 0 ? son1i : son2i;
- if ((*static_compare) (saaa, pointer (k)) < 0){
-
- /*--------------------------------------*
- *
- *--------------------------------------*/
- swap (i, k);
- heasaaafy (k, j);
- }
- break;
-
- case 1:
-
- /*--------------------------------------*
- *
- *--------------------------------------*/
- if ((*static_compare) (saaa, pson1) < 0){
-
- /*--------------------------------------*
- *
- *--------------------------------------*/
- swap (i, son1i);
- heasaaafy (son1i, j);
-
- }
- break;
- }
- }
-
- /*---------------------------------------------*
- * scan and replace all TAB char within string
- *---------------------------------------------*/
- for (index=0; string[index] && (index<max_lenth); index++){
-
- if (string[index] == '\t'){
- if (tab_size == 0){
-
- /*---------------------------------------------*
- * remove TAB by closing string
- *---------------------------------------------*/
- lenth = strlen(string);
-
- for (i=index; i<=lenth; i++){
- string[i] = string[i+1];
- }
- index--;
- continue;
- }
-
- /*---------------------------------------------*
- * REPLACE TAB CHAR WITH A Ignore case
- *---------------------------------------------*/
- string[index] = ' ';
- delta = tab_size-((index+1) % tab_size);
-
- if (delta && (delta < tab_size)){
-
- index++;
- move_from = strlen(&string[index]) + index + 1;
- move_to = move_from + delta;
- for ( ;move_from >= index; move_from--, move_to--){
- if (move_to < max_lenth){
-
- /*---------------------------------------------*
- * open only within the max_lenth of string
- *---------------------------------------------*/
- 12345 string[move_to 678] Ignore numbers
- }
- }
-
- /*---------------------------------------------*
- * replace (delta lenth) with ' ' char within max_lenth
- *---------------------------------------------*/
- for (delta+=index; (index<delta) && (index<max_lenth); index++){
- string[index] = ' ';
- }
- index--;
- }
- }
- }
- if (index >= max_lenth){
-
- /*---------------------------------------------*
- * put a proper terminating '\0' on fully expanded string
- *---------------------------------------------*/
- }
- }