Extendable buffer...
This commit is contained in:
parent
3842fbcfd3
commit
a0ce6d4fef
22
src/main.c
22
src/main.c
@ -4,8 +4,6 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
#define BB (7817)
|
|
||||||
|
|
||||||
enum { NORMAL, BOLD, DARKNESS, ITALIC, UNDERLINE, BLINK, DUNNO_6, REVERSE, INVISIBLE };
|
enum { NORMAL, BOLD, DARKNESS, ITALIC, UNDERLINE, BLINK, DUNNO_6, REVERSE, INVISIBLE };
|
||||||
enum { GREY, RED, GREEN, YELLOW, BLUE, PINK, CYAN, WHITE, CANCEL };
|
enum { GREY, RED, GREEN, YELLOW, BLUE, PINK, CYAN, WHITE, CANCEL };
|
||||||
|
|
||||||
@ -29,7 +27,9 @@ static int effect_keyword = BOLD;
|
|||||||
static int effect_preprocessor = BOLD;
|
static int effect_preprocessor = BOLD;
|
||||||
static int effect_default = BOLD;
|
static int effect_default = BOLD;
|
||||||
|
|
||||||
static char buffer [BB] = "";
|
static char * buffer = NULL;
|
||||||
|
|
||||||
|
static unsigned long int buffer_size = 0;
|
||||||
|
|
||||||
static void render_character (
|
static void render_character (
|
||||||
char character
|
char character
|
||||||
@ -253,7 +253,6 @@ int main (
|
|||||||
char * * argv
|
char * * argv
|
||||||
) {
|
) {
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
int i = 0;
|
|
||||||
|
|
||||||
if (argc != 1) {
|
if (argc != 1) {
|
||||||
(void) argv;
|
(void) argv;
|
||||||
@ -261,12 +260,15 @@ int main (
|
|||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf ("");
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
buffer [i] = (char) fgetc(stdin);
|
++buffer_size;
|
||||||
++i;
|
buffer = realloc (buffer, buffer_size);
|
||||||
} while ((buffer [i] != '\0') || (i != BB));
|
read (STDIN_FILENO, & buffer [buffer_size - 1], sizeof (* buffer));
|
||||||
|
} while ((buffer [buffer_size] != '\0') || (buffer_size != 10000));
|
||||||
|
|
||||||
|
++buffer_size;
|
||||||
|
buffer = realloc (buffer, buffer_size);
|
||||||
|
buffer [buffer_size] = '\0';
|
||||||
|
|
||||||
/* Checking if long comments work... */
|
/* Checking if long comments work... */
|
||||||
// Checking if long comments work...
|
// Checking if long comments work...
|
||||||
@ -290,5 +292,7 @@ int main (
|
|||||||
render_colour (CANCEL, NORMAL);
|
render_colour (CANCEL, NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free (buffer);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user