VOGONS


diff and patch for win32

Topic actions

First post, by joe_pool_is

User metadata
Rank Newbie
Rank
Newbie

I have some patches I want to try on my version of DosBox, but they are diff or patch files. I am having a terrible time trying to do all of this manually using Notepad. I did a Google on "diff patch win32." That pulled up half the pages on the Internet, and the relivant links were no longer active.

Are there utilities somewhere?

Wanted: Gasoline and matches.

Reply 1 of 29, by joe_pool_is

User metadata
Rank Newbie
Rank
Newbie

Nevermind. It looks like this utility will work (for those interested):
http://gnuwin32.sourceforge.net/packages/diffutils.htm

Wanted: Gasoline and matches.

Reply 2 of 29, by HunterZ

User metadata
Rank l33t++
Rank
l33t++

Yep, looks like those are Win32 ports of the GNU diff/patch tools that all those *nix people used to make the diff/patch files in the first place. So, those should work well.

Reply 3 of 29, by joe_pool_is

User metadata
Rank Newbie
Rank
Newbie

I installed both diff and patch from the sourceforge download page, then updated my path so that my command line terminal (eh... DOS window?) would know where the new diff.exe and patch.exe files were.

Expecting fabulous results, I typed in "coreswitch.patch" at the prompt. Windows brought up a dialog box asking me to select which program I would like to use to handle files of type .patch. I browsed to the proper directory and selected the patch.exe file. (Patch knows to call diff.exe, I guess?)

Now my terminal appears to be hung:

C:\DOSBox>coreswitch.patch
TMPPATNAME: C:\DOCUME~1\jpool\LOCALS~1\Temp/ppwR1K1R

Okay, now I'm lost! Did I do something incorrect?

Wanted: Gasoline and matches.

Reply 5 of 29, by joe_pool_is

User metadata
Rank Newbie
Rank
Newbie

This is getting frusterating, but how do I "apply" a .diff file? Specifically, I am wanting to apply the "serialport_patch2.diff" file. diff is for getting the difference between two files or folders, so I don't see how this file is used. I apologize for my ignorance.

Wanted: Gasoline and matches.

Reply 7 of 29, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

patch -p0 < serialport_patch.diff

the proper extestion for a patch is confusingly diff (I think ( as patch applies a diff))

Water flows down the stream
How to ask questions the smart way!

Reply 9 of 29, by MiniMax

User metadata
Rank Moderator
Rank
Moderator
Qbix wrote:

patch -p0 < serialport_patch.diff

the proper extestion for a patch is confusingly diff (I think ( as patch applies a diff))

... and the patch program do not care about the extension anyway (as any well-behaved Unix program should).

joe, just a few pointers about that -p0 stuff. Unlike in real life, not all patches are created equal. Some includes extranous path-info (/path/to/some/file-to-patch), some don't. The -p option is used to strip some of that path-info away, allowing patch to find the right file. I think the 0 says "strip the initial /". Depending on the situation, you might have to use -p1, -p2, etc.

Oh - as an alternative to < serialport_patch.diff, you can also use the -i (input option): patch -p0 -i serialport_patch.diff

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 10 of 29, by joe_pool_is

User metadata
Rank Newbie
Rank
Newbie

I really appreciate all the help. Now I seem to be having another problem: When I enter the patch command, I get errors.

C:\>patch -p0 < c:\dosbox\serialport_patch2.diff
can't find file to patch at input line 6
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
-----------------------------
|Index: include/bios.h
|========================================
|RCS file: /cvsroot/dosbox/dosbox/dosbox/include/bios.h,v
|retrieving revision 1.9
|diff -r1.9 bios.h
------------------------------
File to patch: EOF
Skip this patch? [y] ^C
C:\

My directory structure is as follows:

  • * Folder DOSBox is on the C: drive;
    * patch files are located within C:\DOSBox;
    * subfolder "dosbox" is located within C:\DOSBox and contains the 0.63 version from SourceForge.

Where is patch expecting my files to be? Do I need to adjust the -pxxx parameter as MiniMax suggested? If so, what magical value of xxx would/should I use?

Maybe a pic will help:

dosbox.PNG

Wanted: Gasoline and matches.

Reply 12 of 29, by joe_pool_is

User metadata
Rank Newbie
Rank
Newbie

Uh oh! I'm beginning to see new problems.

Previously, I applied the realtime clock patch, and now I am trying to apply the serial port patch. Unfortunately, the realtime clock patch seems to have modified some of the same code that the serial port patch needs to modify.

The serial port patch says to do this:

238,240c848,851
< for (i=base;i<=(base+8);i++) {
< IO_RegisterWriteHandler(i+8,WriteSerial,IO_MB);
< IO_RegisterReadHandler(i+8,ReadSerial,IO_MB);
---
> for (i=base;i<=(base+8);i++)
> {
> IO_RegisterWriteHandler(i,WriteSerial,IO_MB);
> IO_RegisterReadHandler(i,ReadSerial,IO_MB);

whereas that section of serialport.cpp reads as:

for (i=0;i<=8;i++) {
WriteHandler[i].Install(base+i+8,WriteSerial,IO_MB);
ReadHandler[i].Install(base+i+8,ReadSerial,IO_MB);
}

Does anyone have a suggestion that would help me modify this? I feel only mildly wrong by modifying the for loop to include the base number, but I am at a loss of what to do about the two different types of functions being called. Should I call them both, or is one set better than another? (Should this be the topic of a new thread? I hate seeing my name on so many threads on here.)

Wanted: Gasoline and matches.

Reply 13 of 29, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

you seem to using old patches.
are you certain you are using the latest version of the serial port patch ?

Water flows down the stream
How to ask questions the smart way!

Reply 14 of 29, by MiniMax

User metadata
Rank Moderator
Rank
Moderator
Qbix wrote:

run the patch from c:\dosbox\

Aren't you short of a DOSBox there, Qbix?

The magic word in that patch is Index: include/bios.h. With C:\DOSBox\dosbox as your working directory, the path should match.

For pure entertainment value, you could try going one level down to C:\DOSBox\dosbox\include, and try a -p1 to have patch ignore the include part.

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 16 of 29, by joe_pool_is

User metadata
Rank Newbie
Rank
Newbie

Qbix wrote:

you seem to using old patches.
are you certain you are using the latest version of the serial port patch ?

Uh... I thought I was. I downloaded serialport_patch2.diff from SourceForge, as it had a newer date on it than serialport_patch.diff did. Is there something else I should have used? (Drats!)

Wanted: Gasoline and matches.

Reply 17 of 29, by h-a-l-9000

User metadata
Rank DOSBox Author
Rank
DOSBox Author

The latest version is in
DirectSerial patch

Since I used the february CVS as my base, a diff file would cause the same problem, and I didn't make one. I put all files I modified in a folder.

Reply 18 of 29, by joe_pool_is

User metadata
Rank Newbie
Rank
Newbie

h-a-l-9000,

I downloaded dosboxserial2.zip from your thread.

When I tried to compile, I got that a few things were missing.

  • On bios.h, I had to add BIOS_COM3_TIMEOUT and BIOS_COM4_TIMEOUT;
  • I added the contents of the dosbox\src\hardware\serialport folder to my project

There must be something else missing that I can't find, because I am currently getting these errors when compiling (ignore the warnings):

------ Build started: Project: dosbox, Configuration: Release Win32 ------

Compiling...
sdlmain.cpp
\DOSBox\dosbox_hal\src\gui\sdlmain.cpp(1154) : warning C4297: 'SDL_main' : function assumed not to throw an exception but does
__declspec(nothrow) or throw() was specified on the function
\DOSBox\dosbox_hal\src\gui\sdlmain.cpp(1154) : warning C4297: 'SDL_main' : function assumed not to throw an exception but does
__declspec(nothrow) or throw() was specified on the function
directserial.cpp
\DOSBox\dosbox_hal\src\hardware\serialport\directserial.cpp(37) : fatal error C1083: Cannot open include file: 'qextserialport.h': No such file or directory
serialdummy.cpp
\DOSBox\dosbox_hal\src\hardware\serialport\serialdummy.cpp(43) : error C2661: 'CSerial::CSerial' : no overloaded function takes 6 arguments
\DOSBox\dosbox_hal\src\hardware\serialport\serialdummy.cpp(46) : error C2039: 'Init_Registers' : is not a member of 'CSerial'
../include\serialport.h(103) : see declaration of 'CSerial'
\DOSBox\dosbox_hal\src\hardware\serialport\serialdummy.cpp(46) : error C3861: 'Init_Registers': identifier not found, even with argument-dependent lookup
\DOSBox\dosbox_hal\src\hardware\serialport\serialdummy.cpp(74) : error C3861: 'changeMSR': identifier not found, even with argument-dependent lookup
\DOSBox\dosbox_hal\src\hardware\serialport\serialdummy.cpp(81) : error C3861: 'ByteTransmitted': identifier not found, even with argument-dependent lookup
Generating Code...

Build Time 0:06
Build log was saved at "file://c:\DOSBox\dosbox_hal\visualc_net\Release\BuildLog.htm"
dosbox - 6 error(s), 2 warning(s)


---------------------- Done ----------------------

Build: 0 succeeded, 1 failed, 0 skipped

Is there a file of definitions that I am missing?

Wanted: Gasoline and matches.

Reply 19 of 29, by joe_pool_is

User metadata
Rank Newbie
Rank
Newbie

h-a-l-9000,

The missing file is: 'qextserialport.h'

Could you send it? Does it also go in the same hardware\serialport folder?

Wanted: Gasoline and matches.