Closed
Bug 71429
Opened 24 years ago
Closed 17 years ago
javascript print command always carriage returns
Categories
(Core :: JavaScript Engine, enhancement)
Tracking
()
RESOLVED
WONTFIX
People
(Reporter: emberson, Unassigned)
Details
Attachments
(1 file)
(deleted),
patch
|
Details | Diff | Splinter Review |
From Bugzilla Helper:
User-Agent: Mozilla/4.76 [en] (X11; U; Linux 2.2.14-5.0 i686)
BuildID: JavaScript-C 1.5 pre-release 3 2001-03-07
static JSBool
Print(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
uintN i, n;
JSString *str;
for (i = n = 0; i < argc; i++) {
str = JS_ValueToString(cx, argv[i]);
if (!str)
return JS_FALSE;
fprintf(gOutFile, "%s%s", i ? " " : "", JS_GetStringBytes(str));
}
n++;
if (n)
fputc('\n', gOutFile);
return JS_TRUE;
}
It always produces a carriage return. how about adding a flag like
'-n' and if this argument is present, then no carriage return is
produced.
Also, the variable 'n' is not needed.
Reproducible: Always
Steps to Reproduce:
1.print("");
2.
3.
Actual Results: you get a carriage return
In the javascript version of the junit test harness, when run with
a text-based 'test-runner' it produces a 'progress bar' which is
simply a row of '.', eg:
.......
but here it produces a vertial column instead:
.
.
.
.
.
Comment 1•24 years ago
|
||
Confirming for evaluation by JS team -
Status: UNCONFIRMED → NEW
Ever confirmed: true
Updated•23 years ago
|
Severity: minor → enhancement
Target Milestone: --- → Future
xpcshell has a dump() function ... would people be interested in that?
Comment 4•22 years ago
|
||
How would you add such a flag? The function takes any number of arguments.
I found this omission a little odd myself. I'd rather see something like print
and println, similar to Pascal's write and writeln.
In the end, I find I rarely need this. Generally I stuff things into a string
and then print that rather than printing intermediate results. The progress bar
is one of the few exceptions.
Can't say I really like dump as a solution, as it's fairly different from the
behavior defined by print. Oddly enough it has Mac line ending translation.
Updated•19 years ago
|
Assignee: khanson → general
QA Contact: pschwartau → general
Target Milestone: Future → ---
Comment 5•17 years ago
|
||
Here's a patch that removes the new line from the output stream. It also removes the useless variable 'n'. Please note that the stream will no longer flush after every call to Print().
Comment 6•17 years ago
|
||
What is the benefit here? Common usage assumes the newline. This change would also require extensive modifications to the test suite. I recommend WONTFIX.
Comment 7•17 years ago
|
||
I vote for WONTFIX, too... This ancient bug has been open forever! What about a new function exactly like print which does -not- append a newline? Is this feature necessary for anything specific?
Comment 8•17 years ago
|
||
I agree with the above statements. I submitted the patch to stimulate discussion (mission accomplished). The ECMAScript spec is silent on the issue of newlines, so I think it's safe to say that the current implementation is ok.
I'll open a new bug to get rid of the useless variable.
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → WONTFIX
Comment 9•17 years ago
|
||
Nevermind, ignore my insanity. This is some weird old code.
You need to log in
before you can comment on or make changes to this bug.
Description
•