The Anonix Project (126, permasaged)

1 Name: Cudder !MhMRSATORI!!L0f5nl0+ : 2008-05-10 06:41 ID:apPW4NZm This thread was merged from the former /code/ board. You can view the archive here.

Since 4chan's /prog/ has become little more than meme spamming, I decided I'd try here.

Me and a group of anons are working on a POSIX-compliant OS, which will be developed anonymously and be public domain. Currently we've started on replacing GNU's Coreutils with Anoncoreutils, and have around 1/3 of the utilities finished. This is both an experiment in anonymous software development and an attempt to eliminate the bloat that GNU's programs tend to have.

Anyone is welcome to join in with this, as long as they don't leave a name and don't mind writing code for the public domain.

More info at http://rechan.eu.org/ac/ and http://rechan.eu.org/ax/

2 Name: #!/usr/bin/anonymous : 2008-05-10 09:11 ID:Heaven

Go away.

You've stolen someone else's tripcode, you're posting with a name so you aren't anonymous, your code quality is terrible and you don't seem to understand the first thing about proper software development, and for the love of god stop spamming your crappy board everywhere.

3 Name: #!/usr/bin/anonymous : 2008-05-10 09:16 ID:Heaven

>>2
I see 4chan's /prog/ is starting to spill over in here.

4 Name: #!/usr/bin/anonymous : 2008-05-10 09:24 ID:Heaven

>>3
No memes used in >>2. Truth is truth regardless of the board it's posted on.

5 Name: #!/usr/bin/anonymous : 2008-05-11 10:22 ID:Heaven

>>1

>to eliminate the bloat that GNU's programs tend to have

:facepalm:

go kill yourself

6 Name: #!/usr/bin/anonymous : 2008-05-11 10:49 ID:EBhnW3dO

>>5
You used a meme. Your argument is invalid.

7 Name: #!/usr/bin/anonymous : 2008-05-11 12:42 ID:Heaven

MEMES EVERYWHERE

8 Name: #!/usr/bin/anonymous : 2008-05-11 14:48 ID:Heaven

>>5
I don't get it. Are you denying that GNU's programs have bloat? I'm not challenging you, I seriously don't get it.

9 Name: #!/usr/bin/anonymous : 2008-05-11 16:30 ID:qbgZMpW+

>>7
in b4 hax my anus, grabs dick, instant.exe, etc.

10 Name: #!/usr/bin/anonymous : 2008-05-11 16:56 ID:omYbeO/h

>>9
Meme this! grabs dick

11 Name: #!/usr/bin/anonymous : 2008-05-11 17:00 ID:rjOJuAmw

Ah, little Cudder. Give up, you seek helpers not where you are supposed to. But then, people at serious programming forums will laugh at your futile attempt at doing something big.

Drop it. I don't want to see you fail.

12 Name: fusian asian : 2008-05-11 17:16 ID:Heaven

>>11

> Drop it. I don't want to see you fail.

Yes, you do. Don't deny it.

13 Name: #!/usr/bin/anonymous : 2008-05-11 17:16 ID:Heaven

>>8

>I don't get it. Are you denying that GNU's programs have bloat? I'm not challenging you, I seriously don't get it.

Are you claiming cat, echo, pwd etc. suffer from bloat? How so?

You can't be fucking serious.

14 Name: #!/usr/bin/anonymous : 2008-05-11 17:22 ID:Heaven

I don't really see what Anonix would contribute other than being some half-assed hackjob of an OS.
Would be better if just sat down and made an editor so we don't have to resort to 70's abandonware.

15 Name: Anonymous : 2008-05-11 17:32 ID:Heaven

hax my anus

16 Name: #!/usr/bin/anonymous : 2008-05-11 17:47 ID:Heaven

>>14
Please, don't mention that.

17 Name: #!/usr/bin/anonymous : 2008-05-11 19:35 ID:q77PlXka

hax my anus

18 Name: #!/usr/bin/anonymous : 2008-05-11 19:48 ID:Heaven

>>13
Heh. Maybe not those...

19 Name: dmpk2k!hinhT6kz2E : 2008-05-11 20:47 ID:Heaven

If you're after small utilities, what's wrong with BusyBox?

This wheel was invented and refined long ago.

20 Name: #!/usr/bin/anonymous : 2008-05-11 21:59 ID:Heaven

Forget your stupid OS! I'm gonna make my own with hookers and blackjack! In fact, forget the OS!

21 Name: #!/usr/bin/anonymous : 2008-05-11 23:08 ID:MtV0H+jp

>>1,13
You have asserted that the GNU tools are "bloated" without further qualifying that statement. I really don't understand why you'd want to reimplement all of GNU coreutils. GNU isn't supposed to be the epitome of Posix programming, it's first goal is to be a free system.

22 Name: HAHAHaruhi!6mHaRuhies : 2008-05-12 03:25 ID:apPW4NZm

>>19
We're not just after small and efficient. BB is GPL, we're going for public domain and small and efficient.

>>13,21

  • GNU cat has 11 more options than POSIX requires, and if you read the spec, at the bottom it says that those options were omitted from the standard because they can be duplicated with sed.
  • For echo, POSIX specifies that ``implementations shall not support any options'' while GNU's version has 4.
  • GNU pwd has two options, but they are not the two that POSIX requires. (We'll probably move pwd into bash though)

We are not reimplementing the GNU coreutils, we are writing POSIX utilities which just so happen to be included in the GNU coreutils. As the Anonix plan indicates, our goal is to develop a public-domain (even more free than GPL, slightly more free than BSD, and anonymous) POSIX implementation.

23 Name: dmpk2k!hinhT6kz2E : 2008-05-12 04:21 ID:Heaven

> public domain

I hope none of your contributors live in the US. If some do I recommend you either do a wee bit more research about the legal situation of public domain code, or they stop contributing.

Why do you think MIT/X11 licences and the like exist?

As an aside, I make regular use at work of echo's -n and -e options (albeit you don't need -n with -e). But if you like life on the spartan side, go for it; UNIX is a pile of crap as is.

24 Name: #!/usr/bin/anonymous : 2008-05-12 05:28 ID:EBhnW3dO

>>23
It is commonly believed by non-lawyers that it is impossible to put a work into the public domain. Although copyright law generally does not provide any statutory means to "abandon" copyright so that a work can enter the public domain, this does not mean that it is impossible or even difficult, only that the law is somewhat unclear. Congress may not have felt it necessary to codify this part of the law, because abandoning property (like a tract of land) to the public domain has traditionally been a matter of common law, rather than statute. (Alternatively, because copyright has traditionally been seen as a valuable right, one which required registration to achieve, it would not have made sense to contemplate someone abandoning it in 1976 and 1988.)[1]

[1] Public domain - Wikipedia, the free encyclopedia. Retrieved on May 12, 2008.

25 Name: #!/usr/bin/anonymous : 2008-05-12 08:25 ID:Heaven

>>22

>GNU cat has 11 more options than POSIX requires, and if you read the spec, at the bottom it says that those options were omitted from the standard because they can be duplicated with sed.

So, what's going to be a worse waste of resources when you need one of those options? Just running "extended" cat, or running both cat and sed? And how much waste are we actually talking about here? Have you ever sat down and done the math? What platform are you targeting that this would actually gain you something?

Surely you'll have pondered these questions before undertaking such an ambitious project.

26 Name: #!/usr/bin/anonymous : 2008-05-12 11:51 ID:Heaven

>>25
If they want to waste their time, then let them. I just wish they'd contribute their efforts to more important problems like free replacements of proprietary programs like Flash or BIOSs.

27 Name: #!/usr/bin/anonymous : 2008-05-12 15:22 ID:BJgX08VW

>>22
hmm, I use echo's -n (don't print a trailing newline) option on BSD all the time. Don't know how I'd write my little hacks and things without it.

28 Name: #!/usr/bin/anonymous : 2008-05-12 18:32 ID:Heaven

Retarded thread is retarded.

29 Name: dmpk2k!hinhT6kz2E : 2008-05-12 19:39 ID:Heaven

>>24

> only that the law is somewhat unclear

Tada.

30 Name: #!/usr/bin/anonymous : 2008-05-13 00:22 ID:apPW4NZm

>>27
Technically POSIX doesn't consider -n to be an option, but it does do what you'd think it should.

31 Name: #!/usr/bin/anonymous : 2008-05-13 08:01 ID:Heaven

>>27

ECHO(1)                 FreeBSD General Commands Manual                ECHO(1)

NAME
echo -- write arguments to the standard output

...

     -n    Do not print the trailing newline character.  This may also be
achieved by appending `\c' to the end of the string, as is done by
iBCS2 compatible systems. Note that this option as well as the
effect of `\c' are implementation-defined in IEEE Std 1003.1-2001
(``POSIX.1'') as amended by Cor. 1-2002. Applications aiming for
maximum portability are strongly encouraged to use printf(1) to
suppress the newline character.

32 Name: !w4lolitaKs : 2008-05-13 08:47 ID:Heaven

To those wondering about the inexact nature of "public domain", here's the official "license" we're going to use:

Permission is hereby granted, free of charge, to any person obtaining
this work (the "Work"), to deal in the Work without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Work, and to permit
persons to whom the Work is furnished to do so.
THE WORK IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE WORK OR THE USE OR OTHER DEALINGS IN THE WORK.

33 Name: #!/usr/bin/anonymous : 2008-05-13 15:42 ID:Heaven

"Talk is cheap. Show me the code."

Linus Torvalds

34 Name: #!/usr/bin/anonymous : 2008-05-13 16:01 ID:U7Lxd9fk

In the EU that license might be equivalent to the (new) BSD license because you cannot abandon certain reputation rights (such as the right to sue someone for using your name, or removing your name from something). In order to effectively do so, you may want to consult a lawyer about including a clause promising not to enact reputation acts where they may exist.

Also: The Berne Convention makes it pretty clear that copyright is implicit and automatic. You may also want to have a lawyer add a clause that says (something to the effect of) "The author(s) intend no additional restrictions in use, except those restrictions that cannot be abandoned by law."

Also: WIPO and the Ninth Circuit Court in the US disagree on whether something whose copyright has been abandoned can be copyrighted someplace else. It is for this reason that many lawyers recommend against using the words "public domain" when referring to a living document with many authors.

Finally, if you're not actually interested in talking to a lawyer, I'd recommend selecting a license that does what you intend. The http://www.opensource.org/licenses has lots of licenses to choose from. It may be a lot easier to start with (for example) the old X.net license, instead of trying to cook up a new one.

35 Name: #!/usr/bin/anonymous : 2008-05-13 16:23 ID:Heaven

> It may be a lot easier to start with (for example) the old X.net license, instead of trying to cook up a new one.

Hey, if their whole project is a case of NIH, why not the license too?

36 Name: HAHAHaruhi!6mHaRuhies : 2008-05-14 06:43 ID:apPW4NZm

>>33
http://rechan.eu.org/misc/anoncoreutils/

that's just what we've got since the last update (beginning of May, there'll probably be another one around the beginning of June)

>>35
I think the license we're using is actually the MIT one with some stuff taken out.

>such as the right to sue someone for using your name, or removing your name from something

The thing is, the authors of Anonix have specifically chosen not to use names; or as close as the name Anonymous can convey, anyway.

37 Name: dmpk2k!hinhT6kz2E : 2008-05-14 18:16 ID:Heaven

While I don't understand what you're trying to achieve by rewriting utilities anonymously, I don't want to discourage you from pursuing it. It's a better way to spend your time than a number of things I can think of.

However, I'd like to know why are you posting with a nick and tripcode if you believe enough in the dogma of "Anonymous" to be doing this.

As an aside, your CFLAGS should contain -Wall. Always. In fact -Wall isn't enough, since there are a number of warnings that it doesn't cover, including: -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Wbad-function-cast -Winline --Wredundant-decls

38 Name: #!/usr/bin/anonymous : 2008-05-15 01:39 ID:Heaven

>>37
Doesn't -Wall -W cover all of that? Or at least most.

My usual CFLAGS is -Os -g -ansi -pedantic -Wall -W -Werror.

39 Name: dmpk2k!hinhT6kz2E : 2008-05-15 15:45 ID:Heaven

Unfortunately, they don't.

There are a lot of flags that are more troublesome than they're worth, but the Perl and FreeBSD projects make use of the above listed ones.

-Wall -Wextra (the -W) is pretty good though.

I used to play with Splint as a counterpart to GCC's warnings. It's extremely paranoid though: http://www.splint.org/

40 Name: HAHAHaruhi!6mHaRuhies : 2008-05-15 23:03 ID:Heaven

>However, I'd like to know why are you posting with a nick and tripcode if you believe enough in the dogma of "Anonymous" to be doing this.

We are just the planning group; the code submissions themselves are anonymous.

>>37-39
I believe in ``trust the programmer'', i.e. I know what I'm doing, and if I make a mistake I'm smart enough to figure out what it is; IMHO relying on warnings just offloads too much thought to the (dumb) machine. Other anons working on the project may have their own preferences.

41 Name: #!/usr/bin/anonymous : 2008-05-15 23:25 ID:Heaven

>>40
Your code has bugs. end of story.

42 Name: dmpk2k!hinhT6kz2E : 2008-05-16 00:05 ID:Heaven

You can't be serious, >>40.

Why are you using GCC then? For that matter, why are you using a compiler at all? Hand-compile it!

Machines are good at precision. Humans aren't. You are a complete and utter idiot if that's the reason you don't make use of the tools available to you. You're not a superhuman omniscient entity, regardless of your ego.

Do you believe profilers, debuggers, tests and QA aren't for Real Manly Man Programmers too?

43 Name: #!/usr/bin/anonymous : 2008-05-16 08:31 ID:EBhnW3dO

>>42
I lold
at what a retarded faggot you are

44 Name: #!/usr/bin/anonymous : 2008-05-16 09:08 ID:Heaven

``Anonix'' is quite a succesful trolling endeavor it seems.

45 Name: #!/usr/bin/anonymous : 2008-05-16 14:50 ID:Heaven

bad topic

46 Name: #!/usr/bin/anonymous : 2008-05-16 15:43 ID:n5BHpUt7

>LULZ
> LULZ

47 Name: #!/usr/bin/anonymous : 2008-05-16 17:11 ID:Heaven

Does anonix have jisshin/kashin model?

48 Name: #!/usr/bin/anonymous : 2008-05-16 23:11 ID:Heaven

>>47
I don't think so. These people have said nothing about that. Also, you now need a T-Engine processor to implement these things.

49 Name: Anonymous : 2008-05-16 23:47 ID:Heaven

Ha ha ha. 4-ch has made a better work at trolling you, cdr.

50 Name: HAHAHaruhi!6mHaRuhies : 2008-05-17 04:31 ID:Heaven

>>42
Writing everything in Asm would defeat the portability we're striving for with POSIX. I only know x86 and Z80 Asm.

If you think you can't write perfect code, then you will just accept your imperfection and remain reliant on the compiler/IDE/etc to do your thinking. However, if you constantly strive for perfection, you will come pretty damn close to achieving it. Many are surprised by this, but the key is in thinking very carefully about design before writing a single line of code, and not just throwing things at the compiler until it works.

>>41
I can't tell you which of the anoncoreutils I've written, but all the stuff I've written has no bugs after I'm done. Give me a small unrelated-to-Anonix (solvable) programming problem and I'll write 100% correct code for it.

>>47
wut

51 Name: #!/usr/bin/anonymous : 2008-05-17 08:19 ID:Heaven

whbt, whl. /code/, let's move on.

52 Name: #!/usr/bin/anonymous : 2008-05-17 08:29 ID:Heaven

>>50
write a program that outputs the integer square root of strtoimax(argv[0], NULL, 0) in O(1) time.

53 Name: #!/usr/bin/anonymous : 2008-05-17 11:19 ID:Heaven

Mac  ...a princess and servants
Anonix ...a sadist and masochists
Win  ...a tyrant and slaves

BTRON...a tool and a human

http://4-ch.net/code/kareha.pl/1142746101/

54 Name: #!/usr/bin/anonymous : 2008-05-17 11:29 ID:mYin4QJj

>>53
Vaporware is not a human.

55 Name: HAHAHaruhi!6mHaRuhies : 2008-05-18 01:33 ID:Heaven

>>52
The sqrt of its own name? If you really want that...

#include <math.h>
#include <stdio.h>
#include <inttypes.h>
main(int argc, char **argv) {
printf("%.0Lf\n",floorl(sqrtl((long double)strtoimax(argv[0], NULL, 0))));
}

I'm assuming sqrtl() uses the h/w instruction, which should run in constant time on any CPU made since the early 90s.

56 Name: #!/usr/bin/anonymous : 2008-05-18 06:12 ID:Heaven

>>55
No mister Bond, what you assume is that a intmax_t fits in a long double, which is a false assumption and can lead to program bugs.
Since you didn't define main as a function returning int and rather, you let it be implied, you are not working with C99 but rather C89 and thus you don't have or strtoimax.
You have FAILED.

57 Name: #!/usr/bin/anonymous : 2008-05-18 07:29 ID:Heaven

>>56
Find me an implementation where sizeof(intmax_t) > sizeof(long double).

He(she?) didn't specify the compile options, I tested the code and it works with GCC on a system where sizeof(long double)=12 and sizeof(intmax_t)=8. Including inttypes.h will give you strtoimax(), and as long as libc is C99 compliant it will have the functions as well. >>52 never said anything about what the program should return, so that is irrelevant.

58 Name: #!/usr/bin/anonymous : 2008-05-18 10:40 ID:Heaven

>>56,57
I'm a bit more worried about the argv[0] used here. I don't think it's a very useful input.

59 Name: #!/usr/bin/anonymous : 2008-05-18 11:23 ID:Heaven

>>58
Would be useful if you had wildcard symlinks. (lolwut?)

But I agree, the original problem wasn't that useful anyway; man bc

60 Name: #!/usr/bin/anonymous : 2008-05-18 13:01 ID:Heaven

WTF who needs a licence? JUST USE NONE! (and stay anonymous

61 Name: #!/usr/bin/anonymous : 2008-05-18 17:54 ID:Heaven

>>57
Since the program uses C99 functions, it should conform to C99. That program does not conform to C99 because main is not defined as a function returning int.
As for an implementation where sizeof (intmax_t) > sizeof (long double), even if sizes have nothing to do with it, try lcc-win.
Just because it works on one system means shit.
Look, clearly you and >>55 know shit-all about C, so seriously.

62 Name: #!/usr/bin/anonymous : 2008-05-18 20:49 ID:Rsls/Psh

>>52 here...
>>58
the argv[0] was used because i thought maybe HAHAHaruhi would change it to argv[1], which would be a bug.

but there are other bugs as well:
first...

$ gcc -lm -o hahafail hahafail.c
/var/tmp//ccBv2HKb.o(.text+0x41): In function `main':
: undefined reference to `sqrtl'

second... an intmax_t value is not guaranteed to fit in a long double.

63 Name: HAHAHaruhi!6mHaRuhies : 2008-05-19 01:16 ID:apPW4NZm

>>62

# cat loltest.c
#include <math.h>
#include <stdio.h>
#include <inttypes.h>
main(int argc, char **argv) {
printf("%.0Lf\n",floorl(sqrtl((long double)strtoimax(argv[1], NULL, 0))));
}
# gcc -o loltest -s -Os -lm loltest.c
# gcc --version
gcc (GCC) 4.0.3
...

>>61
It doesn't matter, the code itself is valid C89 and I happen to have C99 libs to link against. If you want it to work on your system then tell me what your type sizes are. And as for main() not returning int, see section 5.1.2.2.3 of the C99 std. "If the return type is not compatible with int, the termination status returned to the host environment is unspecified" -- that's fine, since >>52 didn't say anything about what it should return.

>>52, why don't you show us what you'd write? And as an extra challenge, write fold as per http://www.opengroup.org/onlinepubs/009695399/utilities/fold.html but ignore everything related to internationalisation.

64 Name: #!/usr/bin/anonymous : 2008-05-19 01:41 ID:Heaven

Careful, >>52. HAHAHaruhi is trying to get you to write a piece of his project.

65 Name: #!/usr/bin/anonymous : 2008-05-19 02:53 ID:Rsls/Psh

> It doesn't matter, the code itself is valid C89 and I happen to have C99 libs to link against.

sqrtl isn't in C89 or POSIX. either use C99 or don't.

> If you want it to work on your system then tell me what your type sizes are.

sizeof(long double) is 3
sizeof(intmax_t) is 8
CHAR_BIT is 32.

> >>52, why don't you show us what you'd write?
#include <inttypes.h>
#include <stdint.h>
#include <stdio.h>

#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
#error Please use a compiler that supports the C99 standard to compile this file.
#endif

intmax_t isqrt(intmax_t n){
intmax_t r = 0;
if(0 > n) n = -n;
for(intmax_t i = ~(INTMAX_MAX >> 2) & INTMAX_MAX / 3; i; i >>= 2)
if(n >= (i | r)){
n -= i | r;
r = r >> 1 | i;
} else r >>= 1;
return r;
}

int main(int argc, char *argv[]){
intmax_t n = strtoimax(argv[0], NULL, 0);
printf("%" PRIdMAX "%s\n", isqrt(n), 0 > n ? "i" : "");
return 0;
}

66 Name: #!/usr/bin/anonymous : 2008-05-19 03:16 ID:Heaven

I bet >>52-san is doing this just to show off his OMG OPTIMIZED integer sqrt function.

67 Name: #!/usr/bin/anonymous : 2008-05-19 05:03 ID:Heaven

>>63
YOU FUCKING IDIOT GOD DAMMIT
TRYING TO REFERENCE THE C99 STANDARD TO ME?!?!?!? LLOLOLL
The paragraph you quoted is not even related as it talks about an implicit return, not implicit int.
Look at 5.1.2.2.1 Program Startup. See that you are wrong.

The function called at program startup is named main. The implementation declares no
prototype for this function. It shall be defined with a return type of int and with no
parameters:
int main(void) { /* ... */ }
or with two parameters (referred to here as argc and argv, though any names may be
used, as they are local to the function in which they are declared):
int main(int argc, char *argv[]) { /* ... */ }

No, the code itself is not valid C89.
Fail harder kiddo.

And yes, I can write fold and in fact I've written fold. But you're just trying to make me write something for you.

68 Name: Cudder !MhMRSATORI!!L0f5nl0+ : 2008-05-19 12:39 ID:Heaven

Hmm... you forgot the fourth or-part of the 5.1.2.2.1 clause.

>or in some other implementation-defined manner.
>No, the code itself is not valid C89.
$ gcc -std=c89 -c abcxyz.c
$ ls abcxyz.o
abcxyz.o
$

lolwut? with -Wall there's a 'return type defaults to int' warning, but I guess that was to be expected. Works fine after linking with -lm.

BTW, aCU has fold already, it was finished several days ago. Wait until the June update, or if you really want proof I can post the source here.

Now defer any assessments of the abilities of the Anonix programmers until the June update; also, regarding the "X isn't c-whatever-standard" or "X won't work on a system with Y" complaints; for the former, all we're concerned is that the utilities do what the POSIX spec says, and for the latter -- do you have such a system where it won't work? No? Non-existent systems don't matter. Even Linux started out being i386-only.

69 Name: #!/usr/bin/anonymous : 2008-05-19 13:46 ID:Heaven

>>68
That's for freestanding implementations, you really don't know your shit.
The code is not valid C89. You lied about gcc's output, because you didn't even include the math library! You blatant liar!
http://www.schweikhardt.net/identifiers.html
intmax_t -> C99. Just deal with it, your code is not valid C89.
And lastly, yes, post the source here. Or give us a link to the source. So I can show you how many errors you have.
Your remark about linux and i386 shows how ignorant you are.

70 Name: Cudder !MhMRSATORI!!L0f5nl0+ : 2008-05-20 01:09 ID:Heaven

I included the file which defined intmax_t, I could've easily typedef'd it with the largest integer type the compiler supported (long long in this case). I didn't include the math lib because I'm only compiling, not linking.

Your remark about "Your remark about linux and i386 shows how ignorant you are" shows how ignorant you are.

>I'm doing a (free) operating system (just a hobby, won't be big and professional like gnu) for 386(486) AT clones.
>for 386(486) AT clones
>386
>...
>It is NOT portable (uses 386 task switching etc)

fold coming in next post

71 Name: #!/usr/bin/anonymous : 2008-05-20 01:31 ID:Heaven

/* @fold.c */
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>

/* TODO: possible memory limit on huge lines and -s? */

extern char *optarg;
extern int optind,optopt;

int col=0;

char *linebuf;
char *lsp;
char *remain_ptr;
int linebuf_size;
int linebuf_used;
int remain_cnt;

int (*foldgetc)(FILE *)=fgetc;

int fold_get(FILE *f) {
if(remain_cnt) {
remain_cnt--;
return *(remain_ptr++);
} else
return fgetc(f);
}

int main(int argc, char **argv) {
int width = 80, bflag=0, sflag=0, retval=0;
int i;
FILE *f;

while((i=getopt(argc,argv,"bsw:"))!=-1) {
switch(i) {
case 'b':
bflag=1;
break;
case 's':
sflag=1;
foldgetc=fold_get;
break;
case 'w':
if((width=atoi(optarg))<1) {
fprintf(stderr,"%s: invalid width %d\n",argv[0],width);
return 1;
}
break;
case '?':
fprintf(stderr,"%s: invalid option %c\n",argv[0],optopt);
return 1;
}
}
if(argc==optind) {
f=stdin;
i=argc;
goto fold_stdin;
} else
i=optind;
while(i<argc) { /* loop for each file */
int c;
if(!(f=fopen(argv[i++],"rb"))) {
fprintf(stderr,"%s: error opening %s: %s\n",argv[0],argv[i-1],strerror(errno));
retval|=1;
continue;
}
fold_stdin:
if(sflag && !linebuf) {
if(!(linebuf=malloc(80))) {
fprintf(stderr,"%s: cannot allocate line buffer\n",argv[0]);
return 1;
} else
linebuf_size=80;
}
while((c=foldgetc(f))!=EOF) { /* folding loop */
if(c=='\n') {
if(sflag && linebuf && linebuf_used) {
fwrite(linebuf,1,linebuf_used,stdout);
linebuf_used=0;
lsp=0;
}
putchar('\n');
col=0;
continue;
}
if(!bflag) {
switch(c) {
case '\t':
col=(col/8+1)*8;
break;
case '\b':
col=col?col-1:0;
break;
case '\r':
col=0;
break;
default:
col++;
}
} else
col++;
if(col>width) {
col=1;
if(sflag && linebuf) { /* release stored line */
fwrite(linebuf,1,lsp?(lsp-linebuf+1):linebuf_used,stdout);
remain_ptr=lsp?lsp+1:0;
remain_cnt=lsp?linebuf_used-(lsp-linebuf+1):0;
lsp=0;
linebuf_used=0;
ungetc(c,f);
putchar('\n');
col=0;
continue;
}
putchar('\n');
}
if(sflag) {
if(linebuf_used>=linebuf_size) {
char *new_linebuf;
if(!(new_linebuf=realloc(linebuf,2*linebuf_size))) {
fprintf(stderr,"%s: not enough memory to process %s\n",argv[0],argv[i-1])
retval=1;
goto outer_continue;
}
linebuf=new_linebuf;
linebuf_size*=2;
}
linebuf[linebuf_used++]=c;
if(c==' ')
lsp=linebuf+linebuf_used-1;
} else
putchar(c);
}
outer_continue:
if(ferror(f)) {
fprintf(stderr,"%s: error reading %s: %s\n",argv[0],argv[i-1],strerror(errno));
retval=1;
}
if(sflag) {
if(linebuf_used)
retval|=fwrite(linebuf,1,linebuf_used,stdout);
linebuf_used=0;
lsp=0;
}
if(f!=stdin)
retval|=fclose(f);
}
if(linebuf)
free(linebuf);
return retval;
}

72 Name: #!/usr/bin/anonymous : 2008-05-20 07:10 ID:Heaven

> do you have such a system where it won't work?

yes. i compile everything with -pedantic -Wall -W -Werror, and optionally std=c99. if it doesn't compile with those, it's broken.

73 Name: #!/usr/bin/anonymous : 2008-05-20 07:52 ID:Heaven

>>70
chgrp.c, chown.c, md5sum.c, mkdir.c, rmdir.c, and sha1sum.c don't compile because of syntax errors. mkfifo.c assumes mode_t is signed, which it isn't on my system. tty.c contains a syntax error but gcc compiles it anyway.

xxxxxx@olorin$ wget -U Mozilla -nd -m -np -E -R html http://rechan.eu.org/misc/anoncoreutils/ >& /dev/null
xxxxxx@olorin$ ls < ~/ac >
ABOUT.HTM chown.c mkdir.c rmdir.c.0 true.c
CODEGUIDELINES chroot.c mkfifo.c robots.txt tty.c
LIST echo.c mkfifo.c.0 sha1sum.c uname.c
NAMING echo.c.0 nice.c sleep.c unlink.c
arch.c false.c nohup.c sync.c whoami.c
basename.c head.c paste.c tee.c yes.c
cat.c link.c pwd.c tee.c.0
chgrp.c md5sum.c rmdir.c touch.c
xxxxxx@olorin$ mkdir bin < ~/ac >
xxxxxx@olorin$ for source in *.c < ~/ac >
for> do
for> gcc -Os -s -pipe -ansi -pedantic $source -o bin/`echo $source|sed s/\.c$//`
for> done
chgrp.c:15: error: syntax error before "do_chgrp"
chown.c:18: error: syntax error before "do_chown"
md5sum.c:2: warning: ISO C90 does not support `long long'
md5sum.c:110: error: syntax error before '/' token
mkdir.c:31: error: syntax error before "int"
mkdir.c: In function `main':
mkdir.c:62: warning: comparison is always false due to limited range of data type
mkfifo.c: In function `main':
mkfifo.c:39: warning: comparison is always false due to limited range of data type
pwd.c:6:2: warning: no newline at end of file
rmdir.c:6: error: syntax error before "void"
rmdir.c:15: error: syntax error before "int"
sha1sum.c:2: warning: ISO C90 does not support `long long'
sha1sum.c:65: error: syntax error before '/' token
sync.c: In function `main':
sync.c:2: warning: return type of 'main' is not `int'
touch.c: In function `main':
touch.c:108: warning: initializer element is not computable at load time
touch.c:108: warning: initializer element is not computable at load time
touch.c:121:2: warning: no newline at end of file
tty.c: In function `main':
tty.c:8: warning: ISO C forbids omitting the middle term of a ?: expression
whoami.c: In function `main':
whoami.c:5: warning: return type of 'main' is not `int'

74 Name: Cudder !MhMRSATORI!!L0f5nl0+ : 2008-05-20 09:11 ID:Heaven

>>73
We are aware of that, and these errors will be fixed in the June update:

  • chown:15 and chgrp:15 had "it" instead of "it"
  • md5sum and sha1sum had C++ comments
  • no idea what was wrong with mkdir, but the updated version compiles fine.
  • same with mkfifo
  • rmdir had inline
Name: Link:
Leave these fields empty (spam trap):
More options...
Verification: