Fix 1993/lmfjyh/README.md
Formatting fixes. Give more of a warning against this entry with gcc < 2.3.3 about it not working and creating a bogus file, referring to the author's comments as to the file name.
This commit is contained in:
1 parent
656a934815
commit
c5c7f4fb75
1 file changed
+132
-106
+132
-106
@@ -7,157 +7,183 @@
|
|||||||
|
|
||||||
## To build:
|
## To build:
|
||||||
|
|
||||||
make all
|
This entry will not compile with gcc < 2.3.3 as it relied on a bug which was
|
||||||
|
fixed in gcc 2.3.3 which was fixed a very long time ago now. If you have such a
|
||||||
|
compiler you can run `make all`.
|
||||||
|
|
||||||
NOTE: This entry will not compile on modern systems because it relies on a
|
**WARNING**: Trying to compile this entry without the affected gcc will also
|
||||||
compiler bug which was fixed in gcc 2.3.3 (a very long time ago now). Trying to
|
make a bogus file on your file system. To delete it you can use the inode
|
||||||
compile it will also make a bogus file on your file system. To delete it you
|
option `-inum` with `find` with the delete option after finding the inode with
|
||||||
can use the inode option `-inum` with `find` with the delete option after
|
`ls -li` or else use a GUI to do it. Should you wish to try compiling it you
|
||||||
finding the inode with `ls -li`.
|
might see something like:
|
||||||
|
|
||||||
### To run
|
NOTE: This will not compile when using modern compilers because
|
||||||
|
it relies on a compiler bug which was fixed in gcc 2.3.3 (a very
|
||||||
|
long time ago now).
|
||||||
|
rm -f \"\;main\(\)\{puts\(\"Hello\ World!\"\)\;\}char\*C=\".c
|
||||||
|
cp lmfjyh.c \"\;main\(\)\{puts\(\"Hello\ World!\"\)\;\}char\*C=\".c
|
||||||
|
cc -std=gnu90 -Wall -Wextra -pedantic -include stdio.h -O3 \
|
||||||
|
\"\;main\(\)\{puts\(\"Hello\ World!\"\)\;\}char\*C=\".c -o lmfjyh
|
||||||
|
Undefined symbols for architecture arm64:
|
||||||
|
"_main", referenced from:
|
||||||
|
implicit entry/start for main executable
|
||||||
|
ld: symbol(s) not found for architecture arm64
|
||||||
|
clang: error: linker command failed with exit code 1 (use -v to see invocation)
|
||||||
|
make: *** [lmfjyh] Error 1
|
||||||
|
|
||||||
|
and the bogus file will be:
|
||||||
|
|
||||||
|
";main(){puts("Hello World!");}char*C=".c
|
||||||
|
|
||||||
|
For an explanation of why this is see the author's comments.
|
||||||
|
|
||||||
|
## To run:
|
||||||
|
|
||||||
|
If you have gcc < 2.3.3:
|
||||||
|
|
||||||
./lmfjyh
|
./lmfjyh
|
||||||
|
|
||||||
## Judges' comments
|
## Judges' comments:
|
||||||
|
|
||||||
See the Makefile for details.
|
|
||||||
|
|
||||||
There's more than one way to get around disk quotas. :-)
|
There's more than one way to get around disk quotas. :-)
|
||||||
|
|
||||||
|
|
||||||
## Author's comments
|
## Author's comments;
|
||||||
|
|
||||||
"Practical and efficient method of compressing source code"
|
"Practical and efficient method of compressing source code".
|
||||||
|
|
||||||
1. Introduction
|
### Introduction
|
||||||
|
|
||||||
I will shortly present a totally new compression method.
|
I will shortly present a totally new compression method.
|
||||||
It may be used to compress any types of files, but it works
|
It may be used to compress any types of files, but it works
|
||||||
best with C-source code.
|
best with C-source code.
|
||||||
|
|
||||||
As an example, I have taken a simple "Hello world!" program
|
As an example, I have taken a simple "Hello world!" program
|
||||||
that should be familiar to all C-programmers.
|
that should be familiar to all C-programmers.
|
||||||
|
|
||||||
Listing 1. A simple "Hello World" program:
|
Listing 1. A simple "Hello World" program:
|
||||||
|
|
||||||
main()
|
|
||||||
{
|
|
||||||
puts("Hello World!");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
2. Packing method
|
main()
|
||||||
|
{
|
||||||
Normally a file name is used only to identify the file,
|
puts("Hello World!");
|
||||||
but this new revolutionary method introduces a totally new concept:
|
}
|
||||||
THE FILE NAME IS THE PROGRAM. There is no need to waste
|
|
||||||
valuable disk space to store source code. The program is
|
|
||||||
embedded in the file name, only a minor portion of it
|
|
||||||
is inside the file.
|
|
||||||
|
|
||||||
Listing 2. Compressed "Hello world":
|
|
||||||
|
|
||||||
char*_=__FILE__;
|
|
||||||
|
|
||||||
|
|
||||||
Listing 3. Code embedded in the file name:
|
### Packing method
|
||||||
|
|
||||||
";main(){puts("Hello World!");}char*C=".c
|
Normally a file name is used only to identify the file,
|
||||||
|
but this new revolutionary method introduces a totally new concept:
|
||||||
|
THE FILE NAME IS THE PROGRAM. There is no need to waste
|
||||||
|
valuable disk space to store source code. The program is
|
||||||
|
embedded in the file name, only a minor portion of it
|
||||||
|
is inside the file.
|
||||||
|
|
||||||
|
Listing 2. Compressed "Hello world":
|
||||||
|
|
||||||
|
|
||||||
The sample program in listing 1 is 36 bytes long. By using the new
|
char*_=__FILE__;
|
||||||
compression method, the example program may be squeezed to sixteen
|
|
||||||
bytes. In the example the compression ratio is 2:1. It is evident
|
|
||||||
that the longer the program is, the better the compression ratio
|
|
||||||
is. The maximum compression ratio in a UNIX environment is 254:16
|
|
||||||
which equals approximately to 16:1. By using the method a one
|
|
||||||
megabyte of source code can be compressed to 64 kilobytes.
|
|
||||||
|
|
||||||
One might easily think that the program could be compressed to a
|
|
||||||
single byte by writing a one character long preprocessor directive
|
|
||||||
in the source file and defining the actual source code in the
|
|
||||||
command line, eg. 'cc hello.c -DX=main(){puts...'. With this
|
|
||||||
method nothing is gained, since the compiling commands must be
|
|
||||||
stored in a file, and that takes even more space than writing the
|
|
||||||
code in a source file as presented in listing 1.
|
|
||||||
|
|
||||||
|
|
||||||
3. Packing files in a UNIX environment
|
Listing 3. Code embedded in the file name:
|
||||||
|
|
||||||
In a UNIX environment it is possible to write almost any program by
|
|
||||||
including the code in file names. Since '/' is used to separate
|
|
||||||
path components and cannot therefore exist in a file name, all
|
|
||||||
features of C-language cannot be used.
|
|
||||||
|
|
||||||
In C, the '/' is used as a division operator and it may also be a
|
|
||||||
part of a comment start and end identifier. This is, however, not a
|
|
||||||
dangerous limitation, since practice has shown that comments are
|
|
||||||
almost totally unnecessary. A real programmer can more easily
|
|
||||||
understand pure source code, and misleading comments are
|
|
||||||
disastrous. The division operation may be replaced with pow(x, -1)
|
|
||||||
and multiplication when using real numbers or with div() function
|
|
||||||
when using integers.
|
|
||||||
|
|
||||||
Large programs must be separated into small modules. This enforces
|
|
||||||
people to write better programs, since monolithic programming style
|
|
||||||
cannot be used. Program development will also be faster, no extra
|
|
||||||
code need not be recompiled after changes have been made.
|
|
||||||
|
|
||||||
|
|
||||||
4. Usage with currently available tools
|
";main(){puts("Hello World!");}char*C=".c
|
||||||
|
|
||||||
I have tested how well this new method works with currently
|
|
||||||
available programming tools.
|
|
||||||
|
|
||||||
Any ANSI conforming C-compiler that runs under a REAL operating
|
The sample program in listing 1 is 36 bytes long. By using the new
|
||||||
system should be able to compile the code. (there may be problems
|
compression method, the example program may be squeezed to sixteen
|
||||||
with some older UNIX variants)
|
bytes. In the example the compression ratio is 2:1. It is evident
|
||||||
|
that the longer the program is, the better the compression ratio
|
||||||
|
is. The maximum compression ratio in a UNIX environment is 254:16
|
||||||
|
which equals approximately to 16:1. By using the method a one
|
||||||
|
megabyte of source code can be compressed to 64 kilobytes.
|
||||||
|
|
||||||
4.1. Compilers:
|
One might easily think that the program could be compressed to a
|
||||||
|
single byte by writing a one character long preprocessor directive
|
||||||
|
in the source file and defining the actual source code in the
|
||||||
|
command line, eg. 'cc hello.c -DX=main(){puts...'. With this
|
||||||
|
method nothing is gained, since the compiling commands must be
|
||||||
|
stored in a file, and that takes even more space than writing the
|
||||||
|
code in a source file as presented in listing 1.
|
||||||
|
|
||||||
|
|
||||||
|
### Packing files in a UNIX environment
|
||||||
|
|
||||||
|
In a UNIX environment it is possible to write almost any program by
|
||||||
|
including the code in file names. Since '/' is used to separate
|
||||||
|
path components and cannot therefore exist in a file name, all
|
||||||
|
features of C-language cannot be used.
|
||||||
|
|
||||||
|
In C, the `/` is used as a division operator and it may also be a
|
||||||
|
part of a comment start and end identifier. This is, however, not a
|
||||||
|
dangerous limitation, since practice has shown that comments are
|
||||||
|
almost totally unnecessary. A real programmer can more easily
|
||||||
|
understand pure source code, and misleading comments are
|
||||||
|
disastrous. The division operation may be replaced with `pow(x, -1)`
|
||||||
|
and multiplication when using real numbers or with `div()` function
|
||||||
|
when using integers.
|
||||||
|
|
||||||
|
Large programs must be separated into small modules. This enforces
|
||||||
|
people to write better programs, since monolithic programming style
|
||||||
|
cannot be used. Program development will also be faster, no extra
|
||||||
|
code need not be recompiled after changes have been made.
|
||||||
|
|
||||||
|
|
||||||
|
### Usage with currently available tools
|
||||||
|
|
||||||
|
I have tested how well this new method works with currently
|
||||||
|
available programming tools.
|
||||||
|
|
||||||
|
Any ANSI conforming C-compiler that runs under a REAL operating
|
||||||
|
system should be able to compile the code. (there may be problems
|
||||||
|
with some older UNIX variants)
|
||||||
|
|
||||||
|
### Compilers:
|
||||||
|
|
||||||
|
These worked:
|
||||||
|
|
||||||
These worked:
|
|
||||||
gcc versions 2.0, 2.1, 2.3.2 (ld failed at AIX with gcc 2.1)
|
gcc versions 2.0, 2.1, 2.3.2 (ld failed at AIX with gcc 2.1)
|
||||||
cc (HP-UX)
|
cc (HP-UX)
|
||||||
cc (VAX)
|
cc (VAX)
|
||||||
|
|
||||||
These failed miserably:
|
These failed miserably:
|
||||||
|
|
||||||
cc (SunOs/Solaris) - could not start cpp properly
|
cc (SunOs/Solaris) - could not start cpp properly
|
||||||
cc/xlc (AIX) - could not open source
|
cc/xlc (AIX) - could not open source
|
||||||
|
|
||||||
4.2. Other tools:
|
### Other tools:
|
||||||
|
|
||||||
4.2.1 Debuggers: (tested at SunOs 4.1.2)
|
#### Debuggers: (tested at SunOs 4.1.2)
|
||||||
|
|
||||||
dbx - Quit with a very 'informative' error message:
|
dbx - Quit with a very 'informative' error message:
|
||||||
"dbx: fatal error: Is a directory"
|
"dbx: fatal error: Is a directory"
|
||||||
|
|
||||||
gdb - Printed almost the same error message ":Is a directory".
|
gdb - Printed almost the same error message ":Is a directory".
|
||||||
It was, however, possible to step through the code but
|
It was, however, possible to step through the code but
|
||||||
not list it.
|
not list it.
|
||||||
|
|
||||||
4.2.2 Lints:
|
#### Lints
|
||||||
|
|
||||||
- None of the lints at tested environments were able
|
None of the lints tested environments were able to parse the file.
|
||||||
to open the file.
|
|
||||||
|
|
||||||
|
|
||||||
5. Conclusions
|
### Conclusions
|
||||||
|
|
||||||
The method can be used to compress any types of files, actually the
|
The method can be used to compress any types of files, actually the
|
||||||
compression ratios are even better when compressing other files
|
compression ratios are even better when compressing other files
|
||||||
than C-source. For example plain text files may be compressed with
|
than C-source. For example plain text files may be compressed with
|
||||||
INFINITE compression ratio. It is trivial task to compress a 100
|
INFINITE compression ratio. It is trivial task to compress a 100
|
||||||
kilobytes long text file in about 400 files whose lengths are zero
|
kilobytes long text file in about 400 files whose lengths are zero
|
||||||
bytes. The drawback is that the files must be unpacked before they
|
bytes. The drawback is that the files must be unpacked before they
|
||||||
can be used, so a large amount of temporary disk space is needed,
|
can be used, so a large amount of temporary disk space is needed,
|
||||||
while C-source is totally usable in the compressed form.
|
while C-source is totally usable in the compressed form.
|
||||||
|
|
||||||
Evidently, there is a long way to go before this new programming
|
Evidently, there is a long way to go before this new programming
|
||||||
technique may be widely used, since currently there are only few
|
technique may be widely used, since currently there are only few
|
||||||
tools supporting it. The advantages over the traditional methods
|
tools supporting it. The advantages over the traditional methods
|
||||||
are, however, so great that there is no doubt that this method will
|
are, however, so great that there is no doubt that this method will
|
||||||
be new standard.
|
be new standard.
|
||||||
|
|
||||||
## Copyright and CC BY-SA 4.0 License:
|
## Copyright and CC BY-SA 4.0 License:
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user