VOGONS

Common searches


Set cycles to specific xt/at/386/486/586 speed.

Topic actions

  • This topic is locked. You cannot reply or edit posts.

Reply 41 of 74, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

I'll take your word on the first

It does what Qbix says, that is accounting for multiple NOTs.

second isn't the same, but same result.

No the result is for example not the same for args:="X Y=" at that point.
Though i don't know if "X Y=" would equal "X=" for msdos, but it could
be if the algorithm checks for a pre-space argument and a post-= argument.

Reply 42 of 74, by ih8registrations

User metadata
Rank Oldbie
Rank
Oldbie

Yep, I had tested later. In case it was misconstrued, I wasn't being snarky.

Nope on the second, they handle "X Y=" the same.
For both stripspaces and while loop:
before args= '==="X Y=" goto pass1'
after args= '==="X Y=" goto pass1'

Doing set var=X Y= in DOS 5.0 results in nothing being set, not var, x, or y.

Reply 43 of 74, by ih8registrations

User metadata
Rank Oldbie
Rank
Oldbie

Alright new patch. Merged his first two changes and added handling of quotes on the left side, it just needed an additional stripword on the first word. set3.diff is cleaned up, set3dirty.diff has logging and his unused changes in comments.

To summarize, the first change actually does something and does something DOS 5.0 does, second you can change to if you prefer, it's in the patch, but either way, third, even if it didn't crash, doesn't do anything constructive, doesn't do what DOS 5.0 does. Perhaps ask him where he got idea DOS 5.0 adds a space at the end to just the right side string, testing says otherwise, set and if evaluation. Fourth, breaks functionality, contrary to DOS 5.0 again.

Attachments

  • Filename
    set3dirty.diff
    File size
    4.17 KiB
    Downloads
    86 downloads
    File license
    Fair use/fair dealing exception
  • Filename
    set3.diff
    File size
    2.96 KiB
    Downloads
    102 downloads
    File license
    Fair use/fair dealing exception

Reply 44 of 74, by etil

User metadata
Rank Newbie
Rank
Newbie

First, I have to apologize for my bad english.

I think that `if' command patch on sf needs explanation. I am sorry if am in the wrong.

The patch does not improve `if' command, has two goal: bug fix and error messages. It behaves like msdos and does not break any functionality (at least I think it).

Write briefly because speak broken English. Use some batch snippets rather. The examples are not from real batch files. They are very simple and silly in some cases.

-	StripSpaces(args);
+// StripSpaces(args);
+
+ // ignore all characters until =
+ while(*args && (*args != '='))
+ args++;
+

Ignoring all characters after last non-space character and before '='.

set var=a b

if %var% == "" echo true!
result in msdos: no echo/error
result in dosbox cvs: syntax error message

if %var% == a echo true!
result in msdos: echoing true!
result in dosbox cvs: syntax error message

-	char* woord2 = StripWord(args);
+// char* woord2 = StripWord(args);
+
+ char* woord2 = args;
+ // Word is until space
+ while(*args && !isspace(*reinterpret_cast<unsigned char*>(args)))
+ args++;
+ if (*args) *args++ = 0;

Words are enclosed in spaces. It seems that msdos does not use double-quotes.

set var=a b

if "%var%" == "" echo true!
result in msdos: no echo/error
result in dosbox cvs: syntax error message

if "%var%" == "a b" echo true!
result in msdos: Bad command or file name error message
result in dosbox cvs: syntax error message

if "%var%" == "a echo true!
result in msdos: echoing true!
result in dosbox cvs: syntax error message

I think that code above is a bug fix.
This code snippet works wrong in current cvs if the batch file is called without command line parameter.

set DRIVE=%1
if not "%1"=="" goto :copy
set DRIVE=c:
:copy

multiple NOTs

-	if (strncasecmp(args,"NOT ",4) ==0) {
+ while (strncasecmp(args,"NOT ",4) ==0) {
args += 4; //skip text
//skip more spaces
StripSpaces(args);
- has_not = true;
+ has_not = !has_not;
}

Probably this modification is unnecessary but msdos works in this way.

if not not a == a echo true!
result in msdos: echoing true!
result in dosbox cvs: syntax error message

Reply 46 of 74, by etil

User metadata
Rank Newbie
Rank
Newbie

continuation

+
+ // Check parameters
+ if (!*word || !*woord2 || (strcasecmp(word,"NOT")==0)) {
+ SyntaxError();
+ return;
+ }
+

Probably this modification is unnecessary. It prints syntax error messages mainly.

expression (!*word):

set var=

if == a echo true!
result in msdos: syntax error message
result in dosbox cvs: no echo/error

if %var% == a echo true!
result in msdos: syntax error message
result in dosbox cvs: no echo/error

if not %var% == a echo true!
result in msdos: syntax error message
result in dosbox cvs: echoing true!

expression (!*woord2):

if a ==
result in msdos: syntax error message
result in dosbox cvs: no error

expression (strcasecmp(word,"NOT")==0):

set var=not
if %var%== "" echo true!
result in msdos: syntax error message
result in dosbox cvs: no echo/error

+	// 2nd word must terminated with space in msdos 5.0 but command line is trimmed in dosbox
+/* else {
+ SyntaxError();
+ return;
+ }
+*/

This modification is for completeness only, prints syntax error message.
It is commented out because works wrong in dosbox.

if a == a<space><end-of-line>
result in msdos: no error
result in dosbox cvs: no error

if a == a<end-of-line>
result in msdos: syntax error message
result in dosbox cvs: no error

To summarize, it works correctly, fixes a bug, does not break any functionality, can check variables with spaces against emptyness. But is not constructive, does not improve`if' command and can not compare two variables containing spaces. At least in my opinion.

Last edited by etil on 2008-11-12, 15:35. Edited 1 time in total.

Reply 49 of 74, by MiniMax

User metadata
Rank Moderator
Rank
Moderator
etil wrote:

Do not understand. Why?

No matter. It is not relevant and commented out.

Doesn't matter? If there is one thing that I hate more than lack of comments, it is misleading comments. If there are no comments, then you read the code and hopefully you can understand what is going on. But if the comments say one thing, and your own understanding of the code says otherwise, who do YOU trust? I tend to trust the person writing the code (and the comments) and it takes me a really long time before I can convince myself that the comments are wrong, and my understanding is correct. And that time is wasted time.

DOSBox 60 seconds guide | How to ask questions
_________________
Lenovo M58p | Core 2 Quad Q8400 @ 2.66 GHz | Radeon R7 240 | LG HL-DT-ST DVDRAM GH40N | Fedora 32

Reply 52 of 74, by etil

User metadata
Rank Newbie
Rank
Newbie

Maybe there are wrong phrases in the comment. I speak broken English.

I tested 2 totally wrong line in msdos 5.0:

if a == a<end-of-line>
There is no space between word `a' and end of line.
Msdos prints syntax error message.

if a == a<space><end-of-line>
There is 1 space between word `a' and end of line.
Msdos prints nothing.

Think that the code does not break string compare. Please give an example.

Reply 53 of 74, by ih8registrations

User metadata
Rank Oldbie
Rank
Oldbie

test.bat:

@echo off

rem var set to "a" no trailing space
set var=a
echo var set as "%var%"

set match=not equal
echo test if "a"=="a"
if "%var%"=="a" set match=equal
echo %match%

set match=not equal
echo test if "a"=="a "
if "%var%"=="a " set match=equal
echo %match%

rem var set to "a " with trailing space
set var=a
echo var set as "%var%"

set match=not equal
echo test if "a "=="a"
if "%var%"=="a" set match=equal
echo %match%

set match=not equal
echo test if "a "=="a "
if "%var%"=="a " set match=equal
echo %match%

set match=not equal
echo test if "a "=="a "
if "%var%"=="a " set match=equal
echo %match%

output of test.bat from DOS 5.0:
A:\>test
var set as "a"
test if "a"=="a"
equal
test if "a"=="a "
not equal
var set as "a "
test if "a "=="a"
not equal
test if "a "=="a "
Bad command or file name
not equal
test if "a "=="a "
Bad command or file name
not equal
A:\>

This shows that set and if don't append a space, and if won't compare a variable with a trailing space to a string with a trailing space.

Take the first if compare of "a"=="a", it correctly compares as equal.
Applying your code of adding a space to the end of just the second string, it would evaluate to not equal. All strings will not match for the same reason, they'll all be off by one character; the space added at the end.

Reply 54 of 74, by ih8registrations

User metadata
Rank Oldbie
Rank
Oldbie

test.bat revealed trailing spaces weren't being passed to the first string, fixed that, dos 5.0 only errors when first and second string have trailing space(s), changed to that behavior, and added the missing error output(not the same as DOS 5.0, but SyntaxError().)

With this, DOSBox behaves the same as DOS 5.0 running test.bat.

Attachments

  • Filename
    set4.diff
    File size
    4.88 KiB
    Downloads
    94 downloads
    File license
    Fair use/fair dealing exception

Reply 57 of 74, by ih8registrations

User metadata
Rank Oldbie
Rank
Oldbie

So.. still at the correct things so setcpu works bit. The issue is passing spaces. The correct or clean fix is to hunt down any and all spots that are relying on spaces not being there and correcting the handling, or hackish way of not fixing all those spots, instead avoiding them/it by keep passing trimmed input to all but that requires handling spaces(if and set.) I've tried the hackish way first but unfortunately the incorrect handling makes use of set so have to dig further.

Reply 58 of 74, by ih8registrations

User metadata
Rank Oldbie
Rank
Oldbie

Yay, simple solution:) Replacing trim with stripspaces does the trick.

Added cleaned up batch info(got rid of some spaces and added some info for 486 & 586.)

Attachments

  • Filename
    setcpu.rar
    File size
    1.64 KiB
    Downloads
    139 downloads
    File license
    Fair use/fair dealing exception
  • Filename
    set5.diff
    File size
    4.9 KiB
    Downloads
    109 downloads
    File license
    Fair use/fair dealing exception