[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #42345] manual should describe incompatibility
From: |
Mike Miller |
Subject: |
[Octave-bug-tracker] [bug #42345] manual should describe incompatibility in fprintf on invalid %-sequence |
Date: |
Wed, 14 May 2014 14:24:35 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20100101 Firefox/17.0 |
Follow-up Comment #16, bug #42345 (project octave):
Sorry, let me clarify some more. Here's what is valid, for printing to
stdout:
fprintf(text);
fprintf(fmt, data_or_string_args, ...);
The following is valid for file descriptors opened with fopen:
fprintf(fid, text);
fprintf(fid, fmt, data_or_string_args, ...);
And for instrument control, according to Matlab's public help:
fprintf(obj, text);
fprintf(obj, fmt, text);
fprintf(obj, text, sync_or_async);
fprintf(obj, fmt, text, sync_or_async);
Those are all valid, but that doesn't make them a good idea. What I'm saying
is, unless you are completely in control of the text string and know that it
contains no % characters, you should always use one of the following:
fprintf('%s', text);
fprintf(fid, '%s', text);
fprintf(obj, '%s', text);
Using fprintf(text) is legal, but not recommended if text may contain a %
character because it may be interpreted into something unexpected.
Now I see that instrument control has some heuristics about line terminators,
since I guess they assume you are talking to some kind of serial device. I
honestly have no idea what instrument control's version of fprintf does with
invalid conversion specifiers or with conversions with no following argument.
But I would hope that it follows the same rules as normal fprintf, in which
case fprintf(obj,'%') and fprintf(obj,'%s') would both result in an empty
string being sent to the device.
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?42345>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #42345] fprintf('''%''') throws error, (continued)
- [Octave-bug-tracker] [bug #42345] fprintf('''%''') throws error, John W. Eaton, 2014/05/13
- [Octave-bug-tracker] [bug #42345] fprintf('''%''') throws error, Mike Miller, 2014/05/13
- [Octave-bug-tracker] [bug #42345] fprintf('''%''') throws error, Stefan Mahr, 2014/05/13
- [Octave-bug-tracker] [bug #42345] fprintf('''%''') throws error, Muhali, 2014/05/13
- [Octave-bug-tracker] [bug #42345] fprintf('''%''') throws error, Michael Godfrey, 2014/05/13
- [Octave-bug-tracker] [bug #42345] fprintf('''%''') throws error, Mike Miller, 2014/05/13
- [Octave-bug-tracker] [bug #42345] manual should describe incompatibility in fprintf on invalid %-sequence, Mike Miller, 2014/05/13
- [Octave-bug-tracker] [bug #42345] manual should describe incompatibility in fprintf on invalid %-sequence, Stefan Mahr, 2014/05/14
- [Octave-bug-tracker] [bug #42345] manual should describe incompatibility in fprintf on invalid %-sequence, Mike Miller, 2014/05/14
- [Octave-bug-tracker] [bug #42345] manual should describe incompatibility in fprintf on invalid %-sequence, Stefan Mahr, 2014/05/14
- [Octave-bug-tracker] [bug #42345] manual should describe incompatibility in fprintf on invalid %-sequence,
Mike Miller <=
- [Octave-bug-tracker] [bug #42345] manual should describe incompatibility in fprintf on invalid %-sequence, Stefan Mahr, 2014/05/14