/* Add replacement string to the output buffer, recognizing special * constructs and replacing them with substrings of the original string. */ static void add_replace(const char *string, regex_t *re, const char *replace, regmatch_t *pm) { const char *p; for (p = replace; *p != '\0'; p++) { if (*p == '&' && !mimic_gnu) { add_sub(0, string, re, pm); continue; } if (*p == '\\') { if (p[1] == '\\') { addchar(p[1]); p++; continue; } if (p[1] == '&') { if (mimic_gnu) add_sub(0, string, re, pm); else addchar(p[1]); p++; continue; } if (isdigit((unsigned char)p[1])) { add_sub(*(++p) - '0', string, re, pm); continue; } } addchar(*p); } }
char *my_modulo(char *n1, char *n2) { t_div *d; d = init_my_mod(n1, n2); if ((d != NULL) && (my_str_isnum(d->dvd) == 1) && (my_str_isnum(d->dvs) == 1)) if (d->dvs[0] != '0') { while (d->dvd[0] != '-') { if ((my_do_op_sub_cmp(d->dvs, d->dvd, 0, 0) == 0) && (d->mod[0] == '0')) my_strcpy(d->mod, d->dvd); my_strcpy(d->temp_cmp, d->dvs); my_strcpy(d->temp_fact, "1"); while (my_do_op_sub_cmp(d->temp_cmp, d->dvd, 0, 0) == 1) add_zero(d); (check_digits(d) == 1) ? (add_zero(d)) : (1); remove_zero(d); if (check_digits(d) == 1) d->temp_fact = add_sub(d->temp_fact, "-1"); get_minus(d->temp_cmp); d->total = add_sub(d->total, d->temp_fact); d->dvd = add_sub(d->dvd, d->temp_cmp); } free(d); return (check_neg(d, d->mod, 2, 0)); } else my_putstr(DIV_0); return (0); }
void parse_sub() { STR namei; INT idi; DOUBLE temp[8]; namei = strtok( NULL, " \t\n" ); if( namei == NULL ) UNERR("Wrong line in " SUB_TAG " no name"); parse_ints( &idi, 1 ); parse_doubles( temp, 8 ); if( strtok( NULL, " \t\n" ) ) UNERR("Wrong line in " SUB_TAG " too many columns"); add_sub(namei,idi,temp[0],temp[1],temp[2],temp[3],temp[4],temp[5],temp[6],temp[7]); }