<commit_before>#! /usr/bin/tcc -run

/*** 
   IO prototype  
   Read a file line by line 
***/

/*** includes ***/

#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <termios.h>
#include <unistd.h>


/*** terminal ***/

struct termios orig_termios;

void die(const char *s) {
  write(STDOUT_FILENO, "\x1b[2J", 4);
  write(STDOUT_FILENO, "\x1b[H", 3);

  perror(s);
  exit(1);
}

void disableRawMode() {
  if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &orig_termios) == -1)
    die("tcsetattr");
}

void enableRawMode() {
  if (tcgetattr(STDIN_FILENO, &orig_termios) == -1) die("tcgetattr");
  atexit(disableRawMode);

  struct termios raw = orig_termios;
  raw.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON);
  raw.c_oflag &= ~(OPOST);
  raw.c_cflag |= (CS8);
  raw.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG);
  raw.c_cc[VMIN] = 0;
  raw.c_cc[VTIME] = 1;

  if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw) == -1) die("tcsetattr");
}

/*** write (to the screen) ***/


int main() {

 enableRawMode();
 int fd = open("test.dat",O_RDONLY);
 char buf;
 int ignore = read(fd,&buf,1);
 write(1,&buf,sizeof(buf));
 write(1,"\n\r",2);
 close(fd);
 exit(0);
}


<commit_msg>Add mods to support a late  getline replacement function<commit_after>#! /usr/bin/tcc -run

/*** 
   IO prototype  
   Read a file line by line 
***/

/*** includes ***/

#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <termios.h>
#include <unistd.h>

/***  formatted printing ***/

void writeDigit(int digit)
{
  char buf[] = "      ";
   snprintf(buf,6,"%d",digit);
   write(STDOUT_FILENO,buf,strlen(buf));
   return;
}

/*** terminal ***/

struct termios orig_termios;

void die(const char *s) {
  write(STDOUT_FILENO, "\x1b[2J", 4);
  write(STDOUT_FILENO, "\x1b[H", 3);

  perror(s);
  exit(1);
}

void disableRawMode() {
  if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &orig_termios) == -1)
    die("tcsetattr");
}

void enableRawMode() {
  if (tcgetattr(STDIN_FILENO, &orig_termios) == -1) die("tcgetattr");
  atexit(disableRawMode);

  struct termios raw = orig_termios;
  raw.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON);
  raw.c_oflag &= ~(OPOST);
  raw.c_cflag |= (CS8);
  raw.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG);
  raw.c_cc[VMIN] = 0;
  raw.c_cc[VTIME] = 1;

  if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw) == -1) die("tcsetattr");
}

/*** write (to the screen) ***/


int main() {

 enableRawMode();
 char line[100];    //
 char* s = &line[0];
 int fd = open("test.dat",O_RDONLY);

 int count; int numb = 0;
// for (count = 0; count < 40; count++)
while(read(fd,s,1)==1)
{
// int ignore = read(fd,s,1);

 if (*s == '\n') {
                  writeDigit(numb);numb = 0;
                  continue;
                 }
 write(1,s,sizeof(*s));
 s++; numb++;
}
 write(1,"\n\r",2);
 close(fd);
 exit(0);
}



{'fraction_non_alphanumeric': 0.20330578512396694, 'fraction_numerical': 0.015206611570247934, 'mean_word_length': 3.577912254160363, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7494173', 'n_tokens_mistral': 1352, 'n_tokens_neox': 1291, 'n_words': 265}