reformatage du REPLCIA

This commit is contained in:
hexplor
2026-03-30 20:35:58 +02:00
parent d2c49cb340
commit 79f42ca4df
4 changed files with 79 additions and 12 deletions
BIN
View File
Binary file not shown.
+2 -1
View File
@@ -2,7 +2,8 @@
/* Le commentaire en dehores du programme */ /* Le commentaire en dehores du programme */
void the_fonction_needed(void){ void the_fonction_needed(void){
printf("YO\n"); //BEGIN
//END
return; return;
} }
BIN
View File
Binary file not shown.
+74 -8
View File
@@ -1,12 +1,78 @@
#include <fcntl.h> #include <stdio.h>
int main(int argc, char** argv){ #include <stdlib.h>
if (argc != 2) #include <string.h>
return 0; #include <ctype.h>
int fd = open(argv[1], O_RDONLY);
if (fd == -1) static char *escape_str(const char *str)
{
if (!str || !str[0])
return NULL;
size_t size = strlen(str);
char *out = malloc(size * 2 + 1);
if (!out)
return NULL;
size_t j = 0;
for (size_t i = 0; i < size; i++)
{ {
printf("fail opening file\n"); if (str[i] == '\n') { out[j++] = '\\'; out[j++] = 'n'; }
return 1; else if (str[i] == '\t') { out[j++] = '\\'; out[j++] = 't'; }
else if (str[i] == '\r') { out[j++] = '\\'; out[j++] = 'r'; }
else if (str[i] == '\\') { out[j++] = '\\'; out[j++] = '\\'; }
else if (str[i] == '"') { out[j++] = '\\'; out[j++] = '"'; }
else if (!isprint((unsigned char)str[i]))
out[j++] = '?';
else
out[j++] = str[i];
} }
out[j] = '\0';
return out;
}
static char *escape_double_quote(const char *str)
{
if (!str || !str[0])
return NULL;
size_t size = strlen(str);
char *out = malloc(size * 2 + 1);
if (!out)
return NULL;
size_t j = 0;
for (size_t i = 0; i < size; i++)
{
if (str[i] == '"') { out[j++] = '\\'; out[j++] = '"'; }
else if (!isprint((unsigned char)str[i]))
out[j++] = '?';
else
out[j++] = str[i];
}
out[j] = '\0';
return out;
}
static into_insert_section(void)
int main(int argc, char **argv)
{
if (argc != 2)
return 1;
FILE *in = fopen(argv[1], "r+");
char* line = NULL;
size_t rded = 0;
if (!in)
return 1;
while (1){
if (getline(&line, &rded, in) == -1)
break;
printf("%s", line);
free(line);
line = NULL;
}
free(line);
fclose(in);
return 0; return 0;
} }