Re: [dev] print utility

From: Calvin Morrison <mutantturkey_AT_gmail.com>
Date: Sat, 30 Mar 2013 22:27:05 -0400

On 30 March 2013 22:27, Charlie Kester <corky1951_AT_comcast.net> wrote:
> On 03/30/2013 18:28, Calvin Morrison wrote:
>>
>> Comrades,
>>
>> I just spend about fifteen minutes writing this little tool that I call
>> print:
>>
>> http://mutantturkey.com/print/
>>
>> All it does is print the specified line from a file.
>>
>> example usage:
>>
>> $ print constitution.txt 1
>> We the People of the United States, in Order to form a more perfect Union,
>>
>> $ print print.c 1
>> #include<stdio.h>
>>
>> todo:
>>
>> pipe from standard input
>>
>> What do you guys think of the tool? Of the code? It does one thing and
>> one thing well.
>
>
>
> I'll assume this is coding exercise, and set aside the questionable need for
> this utility.
>
> - Line 28. Error messages like this should go to stderr. Stdout should
> contain the correct result, or nothing. Adhering to this rule will make
> the program more suitable as a filter in a pipeline.

good catch thank you

> - What guarantee do you have that the input file won't contain any lines
> with length > LINE_MAX? As far as I know, that's an arbitrary number, and
> there is no intrinsic limit on the length of the lines in a Unix text file.

I didn't feel very good about this either.

Is there a better way to read a whole line? fgets requires a length
argument, so I suppose it's not a very good solution

Calvin
Received on Sun Mar 31 2013 - 04:27:05 CEST

This archive was generated by hypermail 2.3.0 : Sun Mar 31 2013 - 04:36:05 CEST