void ft_print_memory(const void *addr, size_t size) { size_t k; size_t l; unsigned char *str; k = -1; str = (unsigned char *)addr; l = (size % 16 == 0) ? size : size + (16 - (size % 16)); while (++k < l) { if (k < size) print_byte(str[k]); else write(1, " ", 2); if (((k + 1) % 2) == 0) ft_putchar(' '); if ((k + 1) % 16 == 0) { (k < size) ? print_dots(str, k - 16, k) \ : print_dots(str, (size - (size % 16) - 1), size - 1); ft_putchar('\n'); } } }
void reconstruct_partition(int s[],int d[MAXN+1][MAXK+1], int n, int k) { if (k==1) print_dots(s,1,n); else { reconstruct_partition(s,d,d[n][k],k-1); print_dots(s,d[n][k]+1,n); } }
static void print_rule(TranslationTableRule *rule) { char *opcode = findOpcodeName(rule->opcode); char *chars; char *dots; char *script; switch (rule->opcode) { case CTO_Context: case CTO_Correct: case CTO_SwapCd: case CTO_SwapDd: case CTO_Pass2: case CTO_Pass3: case CTO_Pass4: script = print_script(&rule->charsdots[rule->charslen], rule->dotslen); printf("%s\t%s\n", opcode, script); break; default: chars = print_chars(rule->charsdots, rule->charslen); dots = print_dots(&rule->charsdots[rule->charslen], rule->dotslen); printf("%s\t%s\t%s\n", opcode, chars, dots); break; } }
int main(void) { print_dots(); return 0; }
// shows time based on mode // 4 digits: hour:min / sec // 6 digits: hour:min:sec / hour-min // 8 digits: hour:min:sec / hour-min-sec void show_time(struct tm* t, bool _24h_clock, uint8_t mode) { dots = 0; uint8_t offset = 0; uint8_t hour = _24h_clock ? t->hour : t->twelveHour; print_dots(mode, t->sec); if (mode == 0) { // normal display mode if (digits == 8) { // " HH.MM.SS " if (!_24h_clock && !t->am) offset = print_ch('P', offset); else offset = print_ch(' ', offset); offset = print_hour(hour, offset, _24h_clock); // wm offset = print_digits(t->min, offset); offset = print_digits(t->sec, offset); offset = print_ch(' ', offset); } else if (digits == 6) { // "HH.MM.SS" offset = print_hour(hour, offset, _24h_clock); // wm offset = print_digits(t->min, offset); offset = print_digits(t->sec, offset); } else { // HH.MM offset = print_hour(hour, offset, _24h_clock); // wm offset = print_digits(t->min, offset); } } else if (mode == 1) { // extra display mode if (digits == 8) { // "HH-MM-SS" offset = print_digits(hour, offset); offset = print_ch('-', offset); offset = print_digits(t->min, offset); offset = print_ch('-', offset); offset = print_digits(t->sec, offset); } else if (digits == 6) { // " HH-MM" offset = print_digits(hour, offset); offset = print_ch('-', offset); offset = print_digits(t->min, offset); if (!_24h_clock && !t->am) offset = print_ch('P', offset); else offset = print_ch(' ', offset); } else { // HH.MM if (_24h_clock) { offset = print_ch(' ', offset); offset = print_digits(t->sec, offset); offset = print_ch(' ', offset); } else { if (t->am) offset = print_ch('A', offset); else offset = print_ch('P', offset); offset = print_ch('M', offset); offset = print_digits(t->sec, offset); } } } }
static char *print_script(widechar *buffer, int length) { static char script[BUFSIZE]; int i = 0; int j = 0; int action = 0; while (i < length) { switch (buffer[i]) { case pass_first: case pass_last: case pass_not: case pass_startReplace: case pass_endReplace: case pass_search: case pass_copy: case pass_omit: append_char(script, &j, buffer[i++]); break; case pass_lookback: append_char(script, &j, buffer[i++]); if (buffer[i] > 1) append_string(script, &j, print_number(buffer[i++])); break; case pass_string: append_char(script, &j, buffer[i]); append_string(script, &j, print_chars(&buffer[i+2], buffer[i+1])); append_char(script, &j, buffer[i]); i += (2 + buffer[i+1]); break; case pass_dots: append_char(script, &j, buffer[i++]); append_string(script, &j, print_dots(&buffer[i+1], buffer[i])); i += (1 + buffer[i]); break; case pass_eq: case pass_lt: case pass_gt: case pass_lteq: case pass_gteq: append_char(script, &j, '#'); append_string(script, &j, print_number(buffer[i+1])); append_char(script, &j, buffer[i]); append_string(script, &j, print_number(buffer[i+2])); i += 3; break; case pass_hyphen: case pass_plus: append_char(script, &j, '#'); append_string(script, &j, print_number(buffer[i+1])); append_char(script, &j, buffer[i]); i += 2; break; case pass_attributes: append_char(script, &j, buffer[i]); append_string(script, &j, print_attributes(buffer[i+1] << 16 | buffer[i+2])); i += 3; if (buffer[i] == 1 && buffer[i+1] == 1) {} else if (buffer[i] == 1 && buffer[i+1] == 0xffff) append_char(script, &j, pass_until); else if (buffer[i] == buffer[i+1]) append_string(script, &j, print_number(buffer[i])); else { append_string(script, &j, print_number(buffer[i])); append_char(script, &j, '-'); append_string(script, &j, print_number(buffer[i+1])); } i += 2; break; case pass_endTest: append_char(script, &j, '\t'); action = 1; i++; break; case pass_swap: case pass_groupstart: case pass_groupend: case pass_groupreplace: /* TBD */ default: i++; break; }} script[j] = 0; return script; }