Branch: Tag:

1997-02-11

1997-02-11 06:58:34 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>

module names capitalized

Rev: lib/include/array.h:1.3
Rev: lib/include/fifo.h:1.3
Rev: lib/include/getopt.h:1.3
Rev: lib/include/process.h:1.3
Rev: lib/include/simulate.h:1.3
Rev: lib/include/stack.h:1.3
Rev: lib/include/stdio.h:1.3
Rev: lib/include/string.h:1.3
Rev: lib/modules/Array.pmod:1.1
Rev: lib/modules/Fifo.pmod:1.1
Rev: lib/modules/Getopt.pmod:1.1
Rev: lib/modules/Process.pmod:1.1
Rev: lib/modules/Simulate.pmod:1.1
Rev: lib/modules/Stack.pmod:1.1
Rev: lib/modules/Stdio.pmod:1.1
Rev: lib/modules/String.pmod:1.1
Rev: lib/modules/array_functions.pmod:1.2(DEAD)
Rev: lib/modules/fifo.pmod:1.2(DEAD)
Rev: lib/modules/getopt.pmod:1.2(DEAD)
Rev: lib/modules/process.pmod:1.2(DEAD)
Rev: lib/modules/simulate.pmod:1.2(DEAD)
Rev: lib/modules/stack.pmod:1.2(DEAD)
Rev: lib/modules/stdio.pmod:1.2(DEAD)
Rev: lib/modules/string_functions.pmod:1.2(DEAD)

1: + #define BEGIN 32    -  + /* +  * Implode an array of strings to an english 'list' +  * ie. ({"foo","bar","gazonk"}) beomces "foo, bar and gazonk" +  */ + string implode_nicely(string *foo, string|void and) + { +  if(!and) and="and"; +  switch(sizeof(foo)) +  { +  case 0: return ""; +  case 1: return foo[0]; +  default: return foo[0..sizeof(foo)-2]*", "+" "+and+" "+foo[-1]; +  } + } +  + string capitalize(string s) + { +  return upper_case(s[0..0])+s[1..sizeof(s)]; + } +  + string strmult(string str, int num) + { + #if 1 +  num*=strlen(str); +  while(strlen(str) < num) str+=str; +  return str[0..num-1]; + #endif + #if 0 +  return sprintf("%~n",str,strlen(str)*num); + #endif + } +  + class String_buffer { +  string *buffer=allocate(BEGIN); +  int ptr=0; +  +  static void fix() +  { +  string tmp=buffer*""; +  buffer=allocate(strlen(tmp)/128+BEGIN); +  buffer[0]=tmp; +  ptr=1; +  } +  +  string get_buffer() +  { +  if(ptr != 1) fix(); +  return buffer[0]; +  } +  +  void append(string s) +  { +  if(ptr==sizeof(buffer)) fix(); +  buffer[ptr++]=s; +  } +  +  mixed cast(string to) +  { +  if(to=="string") return get_buffer(); +  return 0; +  } +  +  void flush() +  { +  buffer=allocate(BEGIN); +  ptr=0; +  } + };   Newline at end of file added.