🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.c
Article #309334

fir's sicl

#309334
From: (fir)
Date: Mon, 07 Aug 2017 17:09
146 lines
3976 bytes
sicl to moja przygodna biblioteczka do pracy z tekstami/plikami tekstowymi w c

nazwa biblioteki to ICL - initial chunk library 
ale ta wersja tutaj to jej brudna napisana na szybko wstepna wersja "small ICL"

pisalem to juz stosunkowo dawno temu i na brudno, dosyc szybko w tydzien / trzy dni czy cos kolo tego (rozmyslan moze i bylo z dwa tygodnie albo i wiecej ale samej roboty to chyba ze trzy dni)

na razie nie chce mi sie wracac do programowania (makm przerwe) ale w sumie moze to zapostuje, na poczatek przeklejam przyklady uzycia

#include "small-icl.c"


//copy a file

int main()
{
  chunk x = LoadChunk("some.exe");
  SaveChunk(x, "copy of some.exe");

  return 0;

}

#include "small-icl.c"

int main()
{
  // append given string to a file

  chunk d = PrintfToChunk("<one %d two %d three %d>", 11,21,31);
  AppendChunkTextMode(d, "alasca.txt");
  return 0;

}


#include "small-icl.c"

int main()
{
  // read text file and add a line numbers to it on the left

  chunk d = LoadChunk("notes.txt");
  chunks s = SplitAfterCharacter(d, 0x0a);

  int len = ChunksLength(s);

  CreateFile("notes with numbered lines.txt");

    for(int i=0; i<len; i++)
    {
      AppendChunk(PrintfToChunk("%d ", i), "notes with numbered lines.txt");
      AppendChunk(s.beg[i], "notes with numbered lines.txt");
    }


  return 0;

}

#include "small-icl.c"

int main()
{

     // extract all integer numbers form given text
     // and print them to the console

     char* text = " we got 7 6 zz5z 89u 83 z-3z9";

     chunk t = Chunk(text);

   for(;;)
   {
     chunk m = FindFirstEmbeddedIntegerChunk(t);

     if(ChunkIsEmpty(m)) break;

     int i = ConvertWordChunk2Int(m);
     printf("%d ",i);

     t.beg=m.end+1;
   }

   return 0;

}

#include "small-icl.c"

int main()
{

     // sort lines in a file,
     // and save sorted

     chunk notes = LoadChunk("notes.txt");
     chunks lines = SplitAfterCharacter(notes, 0x0a);
     Quicksort(lines);
//     NullRepeatingChunks(lines);
     SaveChunks(lines, "notes sorted.txt");


     return 0;

}


#include "small-icl.c"

 void AddInt(int val)
 {
   printf("\n int digged:      %d", val);
 }

int main()
{


   char* txt = "some: 100, 200, 300; then: 3, 4, 5, 6, 7, 8, 9; and then: -10, -20, -30; 1 2 3 4 5 6 2333333333331 1 2 3";

     char* p = txt;
     int value;

     while(DigInt(&p, &value)) AddInt(value);

     return 0;

     // check if given file contains word alice

     chunk notes = LoadChunk("notes.txt");
     chunks lines = SplitAllStdWords(notes);

     int count = 0;

     for(chunk* s = lines.first; s<=lines.last; s++)
     {
       if(Compare(*s, Chunk("alice"))==0)
        count++;
     }

     if(count>0) printf("alice is present");

     return 0;

}
Technical Details
Message-ID: <6950309e-21a6-436f-a500-301fc68754d5@googlegroups.com>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!agh.edu.pl!news.agh.edu.pl!news.cyf-kr.edu.pl!news.nask.pl!news.nask.org.pl!news.unit0.net!news.glorb.com!u14no1005199ita.0!news-out.google.com!e5ni881qta.0!nntp.google.com!w51no981064qtc.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Received: by 10.99.176.13 with SMTP id h13mr791520pgf.177.1502125741414;        Mon, 07 Aug 2017 10:09:01 -0700 (PDT)
X-Received: by 10.31.5.203 with SMTP id 194mr8715vkf.29.1502125741342; Mon, 07 Aug 2017 10:09:01 -0700 (PDT)
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!agh.edu.pl!news.agh.edu.pl!news.cyf-kr.edu.pl!news.nask.pl!news.nask.org.pl!news.unit0.net!news.glorb.com!u14no1005199ita.0!news-out.google.com!e5ni881qta.0!nntp.google.com!w51no981064qtc.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups: pl.comp.lang.c
Date: Mon, 7 Aug 2017 10:09:01 -0700 (PDT)
Complaints-To: groups-abuse@google.com
Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=5.172.255.87; posting-account=Sb6m8goAAABbWsBL7gouk3bfLsuxwMgN
NNTP-Posting-Host: 5.172.255.87
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <6950309e-21a6-436f-a500-301fc68754d5@googlegroups.com>
Subject: fir's sicl
From: "(fir)" <profesor.fir@gmail.com>
Injection-Date: Mon, 07 Aug 2017 17:09:01 +0000
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit