Closed Bug 12768 Opened 20 years ago Closed 20 years ago

Should be const char when pointing to a const char

Categories

(Core :: JavaScript Engine, defect, P3)

Sun
Solaris
defect

Tracking

()

RESOLVED FIXED

People

(Reporter: Dan.Oscarsson, Assigned: jband_mozilla)

Details

strchr on a const char need to be assigned to const char

message is of type const char so you need to assign  the result
of a strchr to a const char. Otherwise a Sun compiler will make an error.

*** mozilla/js/src/xpconnect/shell/xpcshell.cpp.org     Sat Aug 28 13:48:29 1999
--- mozilla/js/src/xpconnect/shell/xpcshell.cpp Sun Aug 29 16:38:07 1999
***************
*** 82,87 ****
--- 82,88 ----
  {
      int i, j, k, n;
      char *prefix = NULL, *tmp;
+     const char *ctmp;

      if (!report) {
          fprintf(gErrFile, "%s\n", message);
***************
*** 102,112 ****
      }

      /* embedded newlines -- argh! */
!     while ((tmp = strchr(message, '\n')) != 0) {
!         tmp++;
          if (prefix) fputs(prefix, gErrFile);
!         fwrite(message, 1, tmp - message, gErrFile);
!         message = tmp;
      }
      /* If there were no filename or lineno, the prefix might be empty */
      if (prefix)
--- 103,113 ----
      }

      /* embedded newlines -- argh! */
!     while ((ctmp = strchr(message, '\n')) != 0) {
!         ctmp++;
          if (prefix) fputs(prefix, gErrFile);
!         fwrite(message, 1, ctmp - message, gErrFile);
!         message = ctmp;
      }
      /* If there were no filename or lineno, the prefix might be empty */
      if (prefix)
Assignee: mccabe → jband
xpcshell is John Bandhauer's.  Sorry for sitting on this...
Status: NEW → ASSIGNED
This is code copied from js.c. If it needs to be fixed here then it needs to be
fixed there too.
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
I checked in this fix for both xpcshell.cpp and js.c

Thanks!
You need to log in before you can comment on or make changes to this bug.