int asm_syntax2_param(char *str, char *tmp, int line) { int i; i = 0; if (tmp[0] == '%') { i++; if (tmp[1] == ':') { if (!ft_isalnum(tmp[2])) asm_put_error_line(str, line); i++; } else if (!ft_isalnum(tmp[1]) && tmp[1] != '-') asm_put_error_line(str, line); } else if (tmp[0] == 'r') { if (!ft_isdigit(tmp[1])) asm_put_error_line(str, line); } else asm_put_error_line(str, line); return (i); }
int main() { char t1[2]; int fd = open("main.c", O_RDONLY); char buf[9]; ft_bzero(buf, 9); ft_strcat(buf, "Ba"); ft_strcat(buf, "j"); ft_strcat(buf, "our."); printf("%s\n", buf); t1[0] = '1'; t1[1] = '\0'; printf("bzero test : %s\n", t1); printf("strlen test : %zu\n", ft_strlen("asd")); printf("strcat test : %s\n", ft_strcat(t1, "ab")); printf("isalpha test : yes %d no %d yes %d no %d\n", ft_isalpha('z'), ft_isalpha('`'), ft_isalpha('A'), ft_isalpha(125)); printf("isdigit test : yes %d no %d yes %d no %d\n", ft_isdigit('1'), ft_isdigit('/'), ft_isdigit('9'), ft_isdigit(':')); printf("isalnum test : yes %d no %d\n", ft_isalnum('1'), ft_isalnum('~')); printf("isascii test : yes %d no %d yes %d no %d\n", ft_isascii('\0'), ft_isascii(-12), ft_isascii(127), ft_isascii(200)); printf("isprint test : yes %d no %d\n", ft_isprint(32), ft_isprint(127)); printf("tolower test : A %c Z %c a %c ~ %c\n", ft_tolower('A'), ft_tolower('Z'), ft_tolower('a'), ft_tolower('~')); printf("toupper test : a %c z %c A %c ~ %c\n", ft_toupper('a'), ft_toupper('z'), ft_toupper('A'), ft_toupper('~')); ft_puts("Hello World"); ft_puts("aaa\n(null)\n"); ft_puts("aaa"); ft_puts(NULL); ft_cat(fd); return (0); }
int main(void) { int i; char *str; str = malloc(3); str[0] = 'a'; str[1] = 'b'; str[2] = 'c'; str[3] = '\0'; i = -128; while (i < 2000) { if (ft_isdigit(i) != isdigit(i)) printf("[FAIL][DIGIT] %d\n", ft_isdigit(i)); if (ft_isalnum(i) != isalnum(i)) printf("[FAIL][ALNUM] %d : %d\n", i, ft_isalnum(i)); i = i + 1; } ft_bzero(str, -1); printf("%c\n", str[0]); printf("%c\n", str[1]); return (0); }
void t_isalnum(void) { printf("\n----- FT_ISALNUM ----- (includes FT_ISDIGIT & FT_ISALPHA)\n"); printf("%c : %d\n", 'a', ft_isalnum('a')); printf("%c : %d\n", '/', ft_isalnum('/')); printf("%c : %d\n", '4', ft_isalnum('4')); printf("%c : %d\n", '\n', ft_isalnum('\n')); printf("%c : %d > %d\n\n", '\200', ft_isalnum('\200'), isalnum('\200')); }
void test_isalnum(void) { int c = 0; printf("\n\n ==========[is_alnum]==========\n"); while (c < 127) { if (ft_isalnum(c)) printf("'%c' : %d\n", c, ft_isalnum(c)); c++; } }
void check_isAlnum() { int i = 0; printf( "--------\nTest ft_isalnum:\n" ); for ( i = MIN; i < MAX; i++ ) { if ( ft_isalnum( i ) != isalnum( i ) ) { printf("[%d] -> result: %d, expected result: %d\n", i, ft_isalnum( i ), isalnum( i ) ); exit( 0 ); } } printf("\033[32mOk\n\033[0m"); }
/* Given a PostScript font name, create the Macintosh LWFN file name. */ static void create_lwfn_name( char* ps_name, Str255 lwfn_file_name ) { int max = 5, count = 0; FT_Byte* p = lwfn_file_name; FT_Byte* q = (FT_Byte*)ps_name; lwfn_file_name[0] = 0; while ( *q ) { if ( ft_isupper( *q ) ) { if ( count ) max = 3; count = 0; } if ( count < max && ( ft_isalnum( *q ) || *q == '_' ) ) { *++p = *q; lwfn_file_name[0]++; count++; } q++; } }
char *gestion_dollar(char *ret, char *str, int *j, int space) { int k; char *tmp; char *aut; char *tip; (*j)++; k = 0; while (ft_isalnum(str[*j + k]) || str[*j + k] == '_') k++; if (k == 0) { ret[ft_strlen(ret)] = '$'; return (ret); } tmp = ft_strndup(str + *j, k - 1); tip = get_str_env(tmp); (void)space; aut = ft_strnew(ft_strlen(ret) + ft_strlen(str + *j) + ft_strlen(tip) + 3); aut = ft_strcpy(aut, ret); aut = ft_strcat(aut, tip); ft_strdel(&ret); ft_strdel(&tmp); *j = *j + k; return (aut); }
static int get_env_variable(t_expander *exp, char *s) { t_env_list *env_var; int len; t_bsh *const bsh = get_shell_data(); len = 0; while (ft_isalnum(*(s + len)) || *(s + len) == '_') len++; if (!len) return (append(exp)); if (!(s = ft_strndup(exp->tmp + 1, len))) return (MALLOC_FAIL); if ((env_var = ft_getenv(bsh->env.env_list, s))) { exp->buffer_len += ft_strlen(env_var->value); while (exp->buffer_len >= exp->buffer_size) if (realloc_exp_buffer(exp) == MALLOC_FAIL) { ft_strdel(&s); return (MALLOC_FAIL); } ft_strcat(exp->buffer, env_var->value); } ft_strdel(&s); exp->tmp += len; return (0); }
int diff_alnum(char test, char target) { int val; int diff; diff = 0; while (test <= target) { printf("Input : %c\n", test); printf("[R] : %d\n[E] : %d\n\n", ft_isalnum(test), isalnum(test)); val = ((ft_isalnum(test)) ? 1 : 0); diff += (isalnum(test) != val ? 1 : 0); test++; } return (diff); }
int asm_syntax_param(char **str, int line, t_btcode *btcode, int j) { char *tmp; int i; int token; tmp = *str; token = 0; i = asm_syntax2_param(*str, tmp, line); while (tmp[i] && (ft_isalnum(tmp[i]) || (tmp[i] == '-' && ++token))) i++; if (token > 1) asm_put_error_line(*str, line); token = 0; asm_set_cmd_param(btcode, ft_strndup(*str, i), j); while (tmp[i] && (tmp[i] == ' ' || tmp[i] == '\t')) i++; if (tmp[i] != ',' && tmp[i] != '\0') asm_put_error_line(*str, line); if (tmp[i] == ',' && ++token) i++; while (tmp[i] && (tmp[i] == ' ' || tmp[i] == '\t')) i++; if (token && tmp[i] == '\0') asm_put_error_line("ENDLINE", line); return (i); }
int termcaps(t_llist *env, t_memory *memo, int len, t_win *win) { struct termios term; int code; init_term(&term, env, win, len); while (win->buffer[0] != RETURN) { ft_bzero(win->buffer, 4); read(0, win->buffer, 4); if (win->buffer[0] == CTRL_D) termcaps_exit("close", &term); if ((ft_isalnum(win->buffer[0])) == 1 || (my_ctrl(win->buffer[0])) == 1) { memo->line = push_line(win->buffer[0], memo->line, win); ft_putchar(win->buffer[0]); } else if ((code = termc_ctrl(memo->line, win, env, memo)) > 0) memo->line = parsing_term(code, memo->line, win); } if (memo->c_t_r + RETURN == TAB + RETURN) tabulation(memo->line, win); bring_back_shell(&term); win->pos[1]++; return (0); }
static void test_3(void) { printf("\ttest 3: ft_isalnum(128): "); if (ft_isalnum(128) == isalnum(128)) puts(SUCCESS); else puts(ERROR); }
static void test_1(void) { printf("\ttest 1: ft_isalnum(-1): "); if (ft_isalnum(-1) == isalnum(-1)) puts(SUCCESS); else puts(ERROR); }
static void ft_check_isalnum(void) { int i; i = -1; while (++i < 128) printf("Value: %d, Ret: %d, char: %c\n", i, ft_isalnum(i), i); }
int ft_isstralnum(char *str) { if (!str || !*str) return (0); while (*str) if (!ft_isalnum(*str++)) return (0); return (1); }
static void big_test(t_test *test) { int i; i = -300; while (!ft_isalnum(i) == !isalnum(i) && i < 255) i++; mt_assert(i == 255); }
int main() { int var1 = 'A'; int var2 = '\t'; int var3 = '@'; int var4 = '5'; if( ft_isalnum(var1) ) { printf("var1 = |%c| is alphanumeric\n", var1 ); } else { printf("var1 = |%c| is not alphanumeric\n", var1 ); } if( ft_isalnum(var2) ) { printf("var2 = |%c| is alphanumeric\n", var2 ); } else { printf("var2 = |%c| is not alphanumeric\n", var2 ); } if( ft_isalnum(var3) ) { printf("var3 = |%c| is alphanumeric\n", var3 ); } else { printf("var3 = |%c| is not alphanumeric\n", var3 ); } if( ft_isalnum(var4) ) { printf("var4 = |%c| is alphanumeric\n", var4 ); } else { printf("var4 = |%c| is not alphanumeric\n", var4 ); } return(0); }
int check_pipes(char *line) { int i; int j; i = 0; j = 0; j += (line[i] && ft_isalnum(line[i]) && line[i] != 'L') ? 1 : 0; while (line[i] && ft_isalnum(line[i])) ++i; j += (line[i] && line[i] == '-') ? 1 : 0; i += (line[i] && line[i] == '-') ? 1 : 0; j += (line[i] && ft_isalnum(line[i]) && line[i] != 'L') ? 1 : 0; while (line[i] && ft_isalnum(line[i])) ++i; if (line[i]) return (0); return (j == 3 ? 1 : 0); }
static int replace_dollar(char **str, int *i) { int j; char *tmp; j = *i; if ((*str)[*i + 1] == '?' || (ft_isalnum((*str)[*i + 1]) == 0 && (*str)[*i + 1] != '_')) { *i += 2; return (0); } while ((*str)[*i + 1] && (ft_isalnum((*str)[*i + 1]) == 1 || (*str)[*i + 1] == '_') && *i - j < 256) (*i)++; tmp = get_replaced(*str, i, j); free(*str); *str = tmp; return (0); }
static int s_check_var(char *var) { size_t i; i = 0; while (var[i] && ft_isalnum(var[i])) ++i; if (var[i] != '\0') return (-1); return (0); }
int main(void) { int i = -10; while (i < 150) { printf("isalnum %i = %i\n", i, isalnum(i)); printf("FT_isalnum %i = %i\n\n", i, ft_isalnum(i)); i++; } return (0); }
static int test_case(char *arg1, int exp) { int res; int exp; res = ft_isalnum(arg1); exp = isalnum(arg1); if (res == exp) return (1); log(arg1, exp, res); return (0); }
static int test_alpha(char *arg) { int i; i = 0; while (arg[i]) { if (!ft_isalnum(arg[i])) return (1); i++; } return (0); }
int ft_strisalnum(char *s) { int i; i = 0; while (s[i]) { if (ft_isalnum(s[i]) == 0 && s[i] != '-' && s[i] != '/') return (0); i++; } return (1); }
int lexer_isponct(char *str, t_token *token) { int i; if (ft_isalnum(str[0]) == 1) return (0); i = 0; while (str[i] != '\0' && ft_isponct(str[i]) == 1) i++; token->typetoken = Ponctuation; token->str = str; token->size = i; return (1); }
int test_isalnum(void) { int test; int diff; test = '0'; diff = 0; printf("---Function #03 : ft_isalnum---\n\n"); printf("For this function, in case of a non-null expected result, "); printf("any non-null result is admited\n\n"); diff += diff_alnum('0', '9'); diff += diff_alnum('A', 'Z'); diff += diff_alnum('a', 'z'); printf("Input : \"\\200\"\n"); printf("[R] : \"%d\"\n[E] : \"%d\"\n\n", ft_isalnum(200), isalnum(200)); if (ft_isalnum(200) > 0) diff++; printf("Input : \"\\13\"\n"); printf("[R] : \"%d\"\n[E] : \"%d\"\n\n", ft_isalnum(13), isalnum(13)); if (ft_isalnum(13) > 0) diff++; return (diff); }
void stat_save(t_game *g) { int press; print_game(g); press = getch(); if (ft_isalnum(press)) ft_pseudo_add_char(g, press); else if (press == 127) ft_pseudo_del_char(g); else if (press == 10) ft_save_pseudo(g); else if (press == 27) ft_del_game(&g); }
int ft_extract_options(char **av, t_options *options) { int i; int j; int k; int value; k = 0; while (k < 122) options->flags[k++] = FALSE; i = 1; while (av[i] && av[i][0] == '-' && ft_isalnum(av[i][1])) { j = 1; while (av[i][j] != '\0' && ft_isalnum(av[i][j])) { value = av[i][j]; options->flags[value] = TRUE; j++; } i++; } return (i); }
char *ft_strcapitalize(char *str) { int i; i = 0; while (str && str[i]) { if (str[i] >= 'a' && str[i] <= 'z') { if (i == 0 || !ft_isalnum(str[i - 1])) str[i] -= 'a' - 'A'; } i++; } return (str); }