packaging updates
authorJoey Hess <joey@gnu.kitenet.net>
Sat, 11 Jul 2009 20:41:32 +0000 (16:41 -0400)
committerJoey Hess <joey@gnu.kitenet.net>
Sat, 11 Jul 2009 20:41:32 +0000 (16:41 -0400)
* scramble: New filter that scambles the inner letters of
  words. Contributed by Andrew J. Buehler.
* Converted debian/copyright to machine parseable format.

Makefile
debian/changelog
debian/copyright
filters.6
makesample.sh
scramble.c [deleted file]
scramble.dir/Makefile [new file with mode: 0644]
scramble.dir/scramble.c [new file with mode: 0644]

index 81a90fca921f44b7bec35ab05918b69f7bdf8848..578678e68fe29b31685dc109f6b492edfd499190 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
 LEX    = flex
-BUILD  = jethro kraut cockney jive nyc ken ky00te newspeak nethackify
+BUILD  = jethro kraut cockney jive nyc ken ky00te newspeak nethackify scramble
 OTHER  = eleet b1ff chef jibberish upside-down rasterman studly fudd \
          censor spammer uniencode pirate kenny scottish fanboy
 CFLAGS = -O2 -lfl
@@ -29,13 +29,14 @@ install:    $(BUILD) $(OTHER)
 
 samples:       $(BUILD) $(OTHER)
        -rm -f SAMPLES
-       PATH=.:$$PATH; export PATH; echo $(BUILD) $(OTHER) |grep -v fanboy |xargs -n 1 sh makesample.sh
+       PATH=.:$$PATH; export PATH; echo $(BUILD) $(OTHER) | xargs -n 1 sh makesample.sh
 
 clean:
-       $(RM) -f core *.o *~ $(BUILD) *.c SAMPLES
+       $(RM) -f core *.o *~ $(BUILD) SAMPLES
        cd ky00te.dir && make clean
        rm -f kraut.dir/lex.yy.c
        cd nethackify.dir && make clean
+       cd scramble.dir && make clean
 
 .SUFFIXES: .l
 
@@ -59,3 +60,6 @@ kraut:
 
 nethackify:
        cd nethackify.dir && make
+
+scramble: 
+       cd scramble.dir && make
index df331be28f3a749e33f0b2706c2f4f8df6373055..8cbdc1e6946baf4247c7f1b5475879ac5d678c99 100644 (file)
@@ -2,6 +2,9 @@ filters (2.47) UNRELEASED; urgency=low
 
   * Patch from Anssi Hannula to avoid warnings when
     compiling with -Werror=format-security.
+  * scramble: New filter that scambles the inner letters of
+    words. Contributed by Andrew J. Buehler.
+  * Converted debian/copyright to machine parseable format.
 
  -- Joey Hess <joeyh@debian.org>  Thu, 09 Jul 2009 22:53:42 -0400
 
index b6b39270014a849badb4464787672e8b9d585103..30631e4f4779419e75730103b51aecfe19930447 100644 (file)
-This is the Debian filters package.
+This is the filters package.
 
-This package was put together and debianized by Joey Hess
-<joeyh@debian.org>, using sources from all over.
+This package was put together by Joey Hess <joeyh@debian.org>, using
+sources from all over.
 
-The jethro filter has this copyright:
-  **   Public domain. Use at your own risk. Y'all come back now, heah?
+Files: *
+Copyright: 1999-2009 Joey Hess <joey@kitenet.net>
+License: GPL-2+
+ The full text of the GPL is distributed as GPL in filters's source,
+ and is distributed in /usr/share/common-licenses/GPL-2 on Debian systems.
 
-The kraut filter has this copyright:
-  /* Kraut v0.9  */
-  /*     by      */
-  /* John Sparks */
-  /*  5-5-1989   */
+Files: jethro.l
+Copyright: 1993 Duane Paulson <ci922@cleveland.freenet.edu>
+License: other
+  **   Public domain. Use at your own risk. Y'all come back now, heah?
 
+Files: kraut.dir/*
+Copyright: 1989 John Sparks
+License: other
   /* This is in the public domain. Do with it as you will. *\
 
-The cockney, jive, and nyc filters are copyright under the GPL by Daniel V
-Klein. He confirmed the new copyright in this email:
-
+Files: cockney.l, jive.l, nyc.l
+Copyright: 1986 Daniel V Klein <dvk@lonewolf.com>
+License: GPL
+ Daniel confirmed the copyright in this email:
+ .
   From: Daniel V Klein <dvk@lonewolf.com>
   Date: Wed, 22 Nov 2000 22:00:50 -0500
   To: Joey Hess <joey@kitenet.net>
   Subject: Re: filters GPL'd 
-  
+ .
   That is so.  Have fun (FWIW, I have done some rewriting on them - they are
   now in Perl, but still need some work...)
-  
+ .
   -Dan
-  
+ .
   > I've been told that you have changed the copyright of the cockney, jive
   > and nyc filters to the GPL? Is that correct? I'd love to move them into
   > Debian proper.
 
-The rasterman filter was pulled out of
-http://www.xach.com/xachbot/xachbot-2000-07-15.tar.gz, which is as a whole
-copyright (C) 1997 Zachary Beane and is GPL'd.
-
-The ken filter is now in the public domain. Its author, Stephen K Mulrine,
-confirmed the new copyright in this email:
+Files: rasterman
+Copyright: 1997 Zachary Beane
+License: GPL
 
+Files: ken.l
+Copyright: Stephen K Mulrine <smulrine%cs.strath.ac.uk@nsfnet-relay.ac.uk>
+License: other
+ The ken filter is now in the public domain. Its author confirmed the
+ new license in this email:
+ .
   From: Stephen Mulrine <stephen@moroder.scotnet.co.uk>
   Date: Mon, 11 Jun 2001 01:06:52 +0100 (BST)
   To: edward@debian.org (Edward Betts)
   Subject: Re: Ken?
-
+ .
   [...]
-
+ .
   >We would like to include ken in the Debian GNU/Linux Operating System, but
   >we need permission to modify ken if we want to. Would you be willing to
   >relicense ken under the GNU GPL, a BSD like license, or public domain?
-
+ .
   Certainly, it would be an honour to have it included in the Debian
   distribution so I hereby release ken into the public domain.
 
-The ky00te filter is now relicensed under the GPL. Its author, Brent
-Edwards, confirmed the new copyright in this email:
-
+Files: ky00te.dir/*
+Copyright: 1994 Brent E. Edwards
+License: GPL
+ The ky00te filter is now relicensed under the GPL. Its author
+ confirmed the new license in this email:
+ .
   From: Brent Edwards <chipuni@hypersurf.com>
   Date: Sat, 30 Jun 2001 09:37:53 -0700
   To: Edward Betts <edward@debian.org>
   Subject: Re: Is this the author of the ky00te filter?
-
+ .
   Dear Edward,
           You have my permission to put the ky00te filter into the GNU GPL
   license.  (Though the license will be far longer than the program itself!)
-
+ .
                           -- Brent Edwards
 
-The newspeak filter is now relicensed under a BSD-like copyright. Its
-author, Jamie Zawinski, established the new copyright in this email:
-
+Files: newspeak.l
+Copyright: 1991 Jamie Zawinski <jwz@jwz.org>
+License: other
+ The newspeak filter is now relicensed under a BSD-like copyright. Its
+ author established the new copyright in this email:
+ .
   From: Jamie Zawinski <jwz@jwz.org>
   Date: Mon, 06 Aug 2001 16:17:02 -0700
   To: Joey Hess <joeyh@debian.org>
   Subject: Re: copyright of newspeak filter
-
+ .
   Hey there -- I'm cleaning out old mail, and don't remember if I replied
   to this or not.  Anyway, in case I didn't -- feel free to slap this 
   license atop the newspeak script (it's BSD-like, so that should work
   for you.)
-
+ .
         Copyright (c) 1991 Jamie Zawinski <jwz@jwz.org>
-
+ .
         Permission to use, copy, modify, distribute, and sell this 
         software and its documentation for any purpose is hereby granted
         without fee, provided that the above copyright notice appear in
@@ -90,27 +106,30 @@ author, Jamie Zawinski, established the new copyright in this email:
         for any purpose.  It is provided "as is" without express or
         implied warranty.
 
-The studly filter is copyright Nick Phillips <nwp@lemon-computing.com> and
-has the following license statement:
-
-# just for reference, you may do whatever you like with this file.
-
-The nethackify filter is copyright 2004 by G�kan Seng�
-<gurkan@linuks.mine.nu> and is released under the gpl.
-
-The pirate filter was converted from a php version in the funfilters, which
-are Copyright 2003 by Dougal Campbell and are licensed under the GPL.
-
-The kenny filter is copyright (C) 2001,2002 by Christian Garbs
-<mitch@cgarbs.de>, Alan Eldridge <alane@geeksrus.net>, and is licensed
-under the Artistic license.
-
-The scottish fileter is copyright 2007 by Adam Borowski
-<kilobyte@angband.pl>, and is licensed under the GPL.
-
-Everything else is copyright 1999-2007 by Joey Hess, under the terms of
-GPL.
-
-On Debian systems, the full text of the GNU GPL can be found in
-/usr/share/common-licenses/GPL and the Artistic license in 
-/usr/share/common-licenses/Artistic
+Files: studly
+Copyright: Nick Phillips <nwp@lemon-computing.com>
+License: other
+ # just for reference, you may do whatever you like with this file.
+
+Files: nethackify
+Copyright: 2004 G�kan Seng� <gurkan@linuks.mine.nu>
+License: GPL
+
+Files: pirate
+Copyright: 2003 Dougal Campbell
+License: GPL
+ Converted from a php version in the funfilters.
+
+Files: kenny
+Copyright:
+  2001 Christian Garbs <mitch@cgarbs.de>
+  2002 Alan Eldridge <alane@geeksrus.net>
+License: Artistic
+ On Debian systems, the full text of the Artistic license can be found in
+ /usr/share/common-licenses/Artistic
+
+Files: scottish
+Copyright: 2007 Adam Borowski <kilobyte@angband.pl>
+License: GPL-3+
+ The full text of the GPL version 3 can be found in 
+ /usr/share/common-licenses/GPL-3 on Debian systems.
index 55c0844aba0ae84401e83894a071ceda962aa053..a9a2995f97c5df18cd6404be6ca5c2a8d7c97b1d 100644 (file)
--- a/filters.6
+++ b/filters.6
@@ -1,6 +1,6 @@
 .TH FILTERS 6
 .SH NAME
-ken, b1ff, censor, chef, cockney, eleet, fanboy, fudd, jethro, jibberish, jive, kenny, kraut, ky00te, nethack, newspeak, nyc, pirate, rasterman, scottish, spammer, studly, uniencode, upside\-down \- assorted text filters
+ken, b1ff, censor, chef, cockney, eleet, fanboy, fudd, jethro, jibberish, jive, kenny, kraut, ky00te, nethack, newspeak, nyc, pirate, rasterman, scottish, spammer, scramble, studly, uniencode, upside\-down \- assorted text filters
 .SH SYNOPSIS
  $SHELL | chef
  
@@ -66,6 +66,9 @@ Fake scottish (dwarven) accent filter, inspired by the character "Durkon"
 from Order of the Stick.
 .IP spammer
 Turns honest text into something that is liable to be flagged as spam.
+.IP scramble
+Scramble the "inner" letters of each word in the input into a random order.
+The resulting text is still strangely readable.
 .IP studly
 Studly caps.
 .IP uniencode
@@ -95,4 +98,5 @@ Stephen K Mulrine <skm@eqsn.net>, newspeak is by Jamie Zawinski
 <jwz@jwz.org>, studly is by Nick Phillips <nwp@lemon\-computing.com>, 
 Gurkan Sengun <gurkan@linuks.mine.nu> wrote nethackify, Dougal Campbell
 <dougal@gunters.org> wrote pirate, kraut is by John Sparks, scottish by
-Adam Borowski, and Kenny is by Christian Garbs and Alan Eldridge.
+Adam Borowski, Kenny is by Christian Garbs and Alan Eldridge,
+and scramble by Andrew J. Buehler.
index dc1f0453271d3e7509c12167cfee0190947c87d4..e7e5e1641e21feb80e2e1698b71f41c686d41651 100644 (file)
@@ -2,6 +2,10 @@
 chmod +x $1
 echo $1 >>SAMPLES
 echo "-------------" >>SAMPLES
-printf "Here's how this filter sounds, in everyday use.\nNow is the time for all good men to come to the aid of their country." | ./$1 >>SAMPLES
+if [ "$1" != fanboy ]; then
+       printf "Here's how this filter sounds, in everyday use.\nNow is the time for all good men to come to the aid of their country." | ./$1 >>SAMPLES
+else
+       printf "This filter has to be tried on real world text to be understood! Oh, and Ubuntu Rules!" >>SAMPLES
+fi
 echo "" >>SAMPLES
 echo "" >>SAMPLES
diff --git a/scramble.c b/scramble.c
deleted file mode 100644 (file)
index 978e06e..0000000
+++ /dev/null
@@ -1,205 +0,0 @@
-/* Scramble the "inner" letters of each word in the input into a random order, and output the result. Non-word (that is, non-alphabetical) characters, and the first and last letters of each word, are left alone.
- * Output to something other than stdout will append to the file instead of overwriting it - this may be undesirable, and can be changed if so.
- */
-
-/* Copyright 2009-07-11 Andrew J. Buehler.
- */
-
-/*   This program is free software: you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License as published by
- *   the Free Software Foundation, either version 3 of the License, or
- *   (at your option) any later version.
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *   You should have received a copy of the GNU General Public License
- *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <stdio.h>
-#include <ctype.h> // for isalpha()
-#include <stdlib.h> // for malloc()/calloc()/realloc()/free() and rand()/srand()
-#include <string.h> // for strlen()
-#include <time.h> // for time()
-
-#define ALLOW_FILE_IO 1
-
-
-/* strips 'reduction' characters from the end of the input string and returns the result
- * works only if strlen(string> >= reduction, which is the case in the only place it is presently called
- */
-char *shorten_string(char *string, int reduction) {
-  int i;
-  
-  i = strlen(string);
-  
-  for (; reduction > 0; reduction--, i--) {
-    string[i-1] = '\0'; // would it work to use an 'i-reduction' approach instead, similar to what was later done in narrow_string()?
-  }
-  
-  return string;
-}
-
-/* strips 'reduction' characters from the beginning and the end of the input string and returns the result
- * works only if(strlen(string) >= 2*reduction), which is the case in the only place it is presently called
- */
-char *narrow_string(char *string, int reduction) {
-  int i = reduction;
-  
-  while(string[i]) {
-    string[i-reduction] = string[i];
-    i++;
-  }
-  string[i-reduction] = '\0';
-  
-  return shorten_string(string, reduction);
-}
-
-int all_one_letter(char *string) {
-  char c;
-  int i;
-  
-  c = string[0];
-  for(i = 1; string[i] != '\0'; i++) {
-    if(c != string[i]) {
-      return 0; // a nonduplicate letter has been found
-    }
-    c = string[i];
-  }
-  
-  return 1; // reached the end of the string having found only duplicate letters, so it's all one letter
-}
-
-/* randomly reorders the contents of the string
- * WARNING: frees the input string and returns a replacement
- */
-char *scramble_string(char *string) {
-  char *ret, *tmpstr;
-  int len, i, j;
-  
-  len = strlen(string);
-  if(len < 2) return string; // can't scramble a 1-character string or an empty string!
-  if(all_one_letter(string)) return(string); // can't scramble a string which consists entirely of one letter!
-  
-  ret = strdup(string);
-  
-  while(strcmp(string, ret) == 0) {
-    j = 0;
-    tmpstr = strdup(string);
-    while(len > 0) {
-      i = rand() % len;
-      ret[j] = tmpstr[i];
-      j++;
-      while(tmpstr[i] != '\0') {
-        tmpstr[i] = tmpstr[i+1];
-        i++;
-      }
-      len--;
-    }
-    free(tmpstr);
-    len = strlen(string);
-  }
-  
-  
-  free(string);
-  return ret;
-}
-
-char *clear_string(char *string) {
-  int i;
-  
-  i = strlen(string);
-  
-  for(; i >= 0 ; i--) {
-    string[i] = '\0';
-  }
-  
-  return string;
-}
-
-int main(int argc, char **argv) {
-  int word_length;
-  char c, tempchar, *word;
-  FILE *infile, *outfile;
-  
-#if ALLOW_FILE_IO
- /* open files, if any other than stdin and stdout */
-  if(argc > 1) {
-    if(!strcmp(argv[1], "--help") ||
-       !strcmp(argv[1], "-h")) {
-      printf("Usage: %s [INPUT_FILENAME] [OUTPUT_FILENAME]\n", argv[0]);
-      printf("If INPUT_FILENAME is omitted or is '-', read from standard input\nIf OUTPUT_FILENAME is omitted or is '-', print to standard output\n");
-      return 0;
-    }
-    
-    if(strcmp(argv[1], "-")) {
-      infile = fopen(argv[1], "r");
-      if(infile == NULL) {
-        fprintf(stderr, "Unable to open input file %s for reading\n", argv[1]);
-        return 1;
-      }
-    } else {
-      infile = stdin;
-    }
-    
-    if(argc > 2) {
-      if(strcmp(argv[2], "-")) {
-        outfile = fopen(argv[2], "a");
-        if(outfile == NULL) {
-          fprintf(stderr, "Unable to open output file %s for writing\n", argv[2]);
-          return 2;
-        }
-      } else {
-        outfile = stdout;
-      }
-    }
-  } else { // no arguments specified
-    infile = stdin;
-    outfile = stdout;
-  }
-#else
-  infile = stdin;
-  outfile = stdout;
-#endif
-
-  srand(time(NULL)); // needed for scramble_string() to actually be random
-  
-  word_length = 0;
-  word = malloc(sizeof(char));
-  word[0] = '\0';
-  c = fgetc(infile);
-  
-  if(feof(infile)) {
-    printf("Reached EOF while reading the first character of the input file!\n");
-    return 4;
-  }
-  
-  while(!feof(infile)) {
-    if(isalpha(c)) {
-      word = realloc(word, word_length+2); // one for the new character, one for the null
-      word[word_length] = c;
-      word[word_length + 1] = '\0'; // duplicate addition with the next line, but possibly more readable
-      word_length++;
-    } else {
-      if(word_length) {
-        word_length--;
-        fputc(word[0], outfile);
-        if(word_length) {
-          tempchar = word[word_length];
-          word = scramble_string(narrow_string(word, 1));
-          fprintf(outfile, "%s", word);
-          fputc(tempchar, outfile);
-        }
-        word = clear_string(word);
-        word_length = 0;
-      }
-      fputc(c, outfile);
-    }
-    fflush(outfile);
-    c = fgetc(infile);
-  }
-  
-  free(word);
-  return 0;
-}
diff --git a/scramble.dir/Makefile b/scramble.dir/Makefile
new file mode 100644 (file)
index 0000000..4b4e7cd
--- /dev/null
@@ -0,0 +1,5 @@
+../scramble: scramble.c
+       $(CC) -o $@ $< -O2 -g
+
+clean:
+       rm -f ../scramble
diff --git a/scramble.dir/scramble.c b/scramble.dir/scramble.c
new file mode 100644 (file)
index 0000000..978e06e
--- /dev/null
@@ -0,0 +1,205 @@
+/* Scramble the "inner" letters of each word in the input into a random order, and output the result. Non-word (that is, non-alphabetical) characters, and the first and last letters of each word, are left alone.
+ * Output to something other than stdout will append to the file instead of overwriting it - this may be undesirable, and can be changed if so.
+ */
+
+/* Copyright 2009-07-11 Andrew J. Buehler.
+ */
+
+/*   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, either version 3 of the License, or
+ *   (at your option) any later version.
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdio.h>
+#include <ctype.h> // for isalpha()
+#include <stdlib.h> // for malloc()/calloc()/realloc()/free() and rand()/srand()
+#include <string.h> // for strlen()
+#include <time.h> // for time()
+
+#define ALLOW_FILE_IO 1
+
+
+/* strips 'reduction' characters from the end of the input string and returns the result
+ * works only if strlen(string> >= reduction, which is the case in the only place it is presently called
+ */
+char *shorten_string(char *string, int reduction) {
+  int i;
+  
+  i = strlen(string);
+  
+  for (; reduction > 0; reduction--, i--) {
+    string[i-1] = '\0'; // would it work to use an 'i-reduction' approach instead, similar to what was later done in narrow_string()?
+  }
+  
+  return string;
+}
+
+/* strips 'reduction' characters from the beginning and the end of the input string and returns the result
+ * works only if(strlen(string) >= 2*reduction), which is the case in the only place it is presently called
+ */
+char *narrow_string(char *string, int reduction) {
+  int i = reduction;
+  
+  while(string[i]) {
+    string[i-reduction] = string[i];
+    i++;
+  }
+  string[i-reduction] = '\0';
+  
+  return shorten_string(string, reduction);
+}
+
+int all_one_letter(char *string) {
+  char c;
+  int i;
+  
+  c = string[0];
+  for(i = 1; string[i] != '\0'; i++) {
+    if(c != string[i]) {
+      return 0; // a nonduplicate letter has been found
+    }
+    c = string[i];
+  }
+  
+  return 1; // reached the end of the string having found only duplicate letters, so it's all one letter
+}
+
+/* randomly reorders the contents of the string
+ * WARNING: frees the input string and returns a replacement
+ */
+char *scramble_string(char *string) {
+  char *ret, *tmpstr;
+  int len, i, j;
+  
+  len = strlen(string);
+  if(len < 2) return string; // can't scramble a 1-character string or an empty string!
+  if(all_one_letter(string)) return(string); // can't scramble a string which consists entirely of one letter!
+  
+  ret = strdup(string);
+  
+  while(strcmp(string, ret) == 0) {
+    j = 0;
+    tmpstr = strdup(string);
+    while(len > 0) {
+      i = rand() % len;
+      ret[j] = tmpstr[i];
+      j++;
+      while(tmpstr[i] != '\0') {
+        tmpstr[i] = tmpstr[i+1];
+        i++;
+      }
+      len--;
+    }
+    free(tmpstr);
+    len = strlen(string);
+  }
+  
+  
+  free(string);
+  return ret;
+}
+
+char *clear_string(char *string) {
+  int i;
+  
+  i = strlen(string);
+  
+  for(; i >= 0 ; i--) {
+    string[i] = '\0';
+  }
+  
+  return string;
+}
+
+int main(int argc, char **argv) {
+  int word_length;
+  char c, tempchar, *word;
+  FILE *infile, *outfile;
+  
+#if ALLOW_FILE_IO
+ /* open files, if any other than stdin and stdout */
+  if(argc > 1) {
+    if(!strcmp(argv[1], "--help") ||
+       !strcmp(argv[1], "-h")) {
+      printf("Usage: %s [INPUT_FILENAME] [OUTPUT_FILENAME]\n", argv[0]);
+      printf("If INPUT_FILENAME is omitted or is '-', read from standard input\nIf OUTPUT_FILENAME is omitted or is '-', print to standard output\n");
+      return 0;
+    }
+    
+    if(strcmp(argv[1], "-")) {
+      infile = fopen(argv[1], "r");
+      if(infile == NULL) {
+        fprintf(stderr, "Unable to open input file %s for reading\n", argv[1]);
+        return 1;
+      }
+    } else {
+      infile = stdin;
+    }
+    
+    if(argc > 2) {
+      if(strcmp(argv[2], "-")) {
+        outfile = fopen(argv[2], "a");
+        if(outfile == NULL) {
+          fprintf(stderr, "Unable to open output file %s for writing\n", argv[2]);
+          return 2;
+        }
+      } else {
+        outfile = stdout;
+      }
+    }
+  } else { // no arguments specified
+    infile = stdin;
+    outfile = stdout;
+  }
+#else
+  infile = stdin;
+  outfile = stdout;
+#endif
+
+  srand(time(NULL)); // needed for scramble_string() to actually be random
+  
+  word_length = 0;
+  word = malloc(sizeof(char));
+  word[0] = '\0';
+  c = fgetc(infile);
+  
+  if(feof(infile)) {
+    printf("Reached EOF while reading the first character of the input file!\n");
+    return 4;
+  }
+  
+  while(!feof(infile)) {
+    if(isalpha(c)) {
+      word = realloc(word, word_length+2); // one for the new character, one for the null
+      word[word_length] = c;
+      word[word_length + 1] = '\0'; // duplicate addition with the next line, but possibly more readable
+      word_length++;
+    } else {
+      if(word_length) {
+        word_length--;
+        fputc(word[0], outfile);
+        if(word_length) {
+          tempchar = word[word_length];
+          word = scramble_string(narrow_string(word, 1));
+          fprintf(outfile, "%s", word);
+          fputc(tempchar, outfile);
+        }
+        word = clear_string(word);
+        word_length = 0;
+      }
+      fputc(c, outfile);
+    }
+    fflush(outfile);
+    c = fgetc(infile);
+  }
+  
+  free(word);
+  return 0;
+}
This page took 0.02399 seconds and 4 git commands to generate.