Bugs item #2942542, was opened at 2010-01-29 22:11
Message generated for change (Comment added) made by nobody
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=111005&aid=2942542&group_id=11005

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: wrong file status after execute shell command "spell"

Initial Comment:
I think any nedit version has the same problem:

1) open a text file with nedit;
2) choose from menu "Shell-->spell". Once the spell window pop up, choose 
"abort";
3) the content in nedit window should remain unmodified, however, the file 
status is changed to "modified".


----------------------------------------------------------------------

Comment By: Nobody/Anonymous (nobody)
Date: 2010-02-13 18:49

Message:
First of all thanks for the reply from the reply.

It seems the attached fix can resolve this problem, but I am not sure if
the fix has any drawbacks.

The idea is to compare two text bufs in "finishCmdExecution()" in
"shell.c", the input and the output to the shell command(s). If they are
identical then the following "safeBufReplace()" won't be invoked.


===============================================================
--- shell_v1.44.c       2010-02-13 11:45:14.000000000 -0600
+++ shell_new.c 2010-02-13 11:55:44.000000000 -0600
@@ -796,11 +796,11 @@
 static void finishCmdExecution(WindowInfo *window, int terminatedOnError)
 {
     shellCmdInfo *cmdData = window->shellCmdData;
     textBuffer *buf;
     int status, failure, errorReport, reselectStart, outTextLen,
errTextLen;
-    int resp, cancel = False, fromMacro = cmdData->fromMacro;
+    int resp, cancel = False, reallytoReplace = True, fromMacro =
cmdData->fromMacro;
     char *outText, *errText = NULL;
 
     /* Cancel any pending i/o on the file descriptors */
     if (cmdData->stdoutInputID != 0)
        XtRemoveInput(cmdData->stdoutInputID);
@@ -814,10 +814,17 @@
     if (cmdData->flags & ERROR_DIALOGS)
        close(cmdData->stderrFD);
     if (cmdData->inPtr != NULL)
        close(cmdData->stdinFD);
 
+    /* Assemble the output from the stdout streams into null
+       terminated strings, and free the buffer lists used to collect it
*/
+    outText = coalesceOutput(&cmdData->outBufs, &outTextLen);
+
+    /* Check if the shell command really changed the content of input */
+    reallytoReplace = strcmp(cmdData->input, outText);
+
     /* Free the provided input text */
     XtFree(cmdData->input);
     
     /* Cancel pending timeouts */
     if (cmdData->flushTimeoutID != 0)
@@ -903,18 +910,22 @@
        if (!BufSubstituteNullChars(outText, outTextLen, buf)) {
            fprintf(stderr,"nedit: Too much binary data in shell cmd output\n");
            outText[0] = '\0';
        }
        if (cmdData->flags & REPLACE_SELECTION) {
-           reselectStart = buf->primary.rectangular ? -1 : buf->primary.start;
-           BufReplaceSelected(buf, outText);
-           TextSetCursorPos(cmdData->textW, buf->cursorPosHint);
-           if (reselectStart != -1)
-               BufSelect(buf, reselectStart, reselectStart + strlen(outText));
+        if (reallytoReplace) {
+            reselectStart = buf->primary.rectangular ? -1 :
buf->primary.start;
+            BufReplaceSelected(buf, outText);
+            TextSetCursorPos(cmdData->textW, buf->cursorPosHint);
+            if (reselectStart != -1)
+                BufSelect(buf, reselectStart, reselectStart +
strlen(outText));
+        }
        } else {
-           safeBufReplace(buf, &cmdData->leftPos, &cmdData->rightPos, outText);
-           TextSetCursorPos(cmdData->textW, cmdData->leftPos+strlen(outText));
+        if (reallytoReplace) {
+            (buf, &cmdData->leftPos, &cmdData->rightPos, outText);
+            TextSetCursorPos(cmdData->textW,
cmdData->leftPos+strlen(outText));
+        }
        }
     }
 
     /* If the command requires the file to be reloaded afterward, reload
it */
     if (cmdData->flags & RELOAD_FILE_AFTER)
===============================================================

----------------------------------------------------------------------

Comment By: Nobody/Anonymous (nobody)
Date: 2010-02-10 21:46

Message:
First thing to check is how the Shell->Spell operation is defined. Use
Preferences-> Default Settings-> Customize Menus-> Shell Menu... to open
the Shell menu definition dialog. In the list, find the entry corresponding
to Spell, and select it. Notice the Command Output radio buttons. If the
"same document" button is active, a replace operation will be executed even
if this has no effect on the content of your document. This could explain
your issue. You can test this by adding a new entry which invokes the
command "cat" which copies its input to its output. I've just tried it and
the effect is exactly as you describe. I don't know what your spell command
actually does, but if "Abort"ing it simply copies its input to its output,
that would explain the modification.

----------------------------------------------------------------------

Comment By: Nobody/Anonymous (nobody)
Date: 2010-02-10 17:34

Message:
is this an easy-fix problem? My knowledge about graphic programming is very
limited. If it is easy, can any developer give me some clues so that I can
try by myself?

Thanks.

----------------------------------------------------------------------

Comment By: Nobody/Anonymous (nobody)
Date: 2010-01-30 00:20

Message:
it seems all the shell commands have the same problem: no matter if the
file content is changed, the file status is always "modified".

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=111005&aid=2942542&group_id=11005
-- 
NEdit Develop mailing list - [email protected]
http://www.nedit.org/mailman/listinfo/develop

Reply via email to