Hello community, here is the log from the commit of package dhex for openSUSE:Factory checked in at 2019-01-24 14:12:35 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/dhex (Old) and /work/SRC/openSUSE:Factory/.dhex.new.28833 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "dhex" Thu Jan 24 14:12:35 2019 rev:2 rq:667640 version:0.69 Changes: -------- --- /work/SRC/openSUSE:Factory/dhex/dhex.changes 2018-01-10 23:34:54.772741647 +0100 +++ /work/SRC/openSUSE:Factory/.dhex.new.28833/dhex.changes 2019-01-24 14:12:36.999417751 +0100 @@ -1,0 +2,8 @@ +Sat Jan 19 20:43:42 UTC 2019 - mar...@gmx.de + +- Update to 0.69: + * fixed a bug which caused the terminal to be broken. + * added the functionality to start the hexcal from the + commandline (-x). + +------------------------------------------------------------------- Old: ---- dhex_0.68.tar.gz New: ---- dhex_0.69.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ dhex.spec ++++++ --- /var/tmp/diff_new_pack.yWsqKm/_old 2019-01-24 14:12:37.483417192 +0100 +++ /var/tmp/diff_new_pack.yWsqKm/_new 2019-01-24 14:12:37.487417188 +0100 @@ -1,7 +1,7 @@ # # spec file for package dhex # -# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,10 +17,10 @@ Name: dhex -Version: 0.68 +Version: 0.69 Release: 0 Summary: Hexeditor with a Diff-mode for ncurses -License: GPL-2.0+ +License: GPL-2.0-or-later Group: Productivity/File utilities URL: http://www.dettus.net/dhex/ Source0: http://www.dettus.net/%{name}/%{name}_%{version}.tar.gz @@ -44,7 +44,8 @@ install -pm 0644 %{name}*.5 %{buildroot}%{_mandir}/man5/ %files -%doc README.txt gpl.txt themes todo.txt +%license gpl.txt +%doc README.txt themes todo.txt %{_bindir}/%{name} %{_mandir}/man?/* ++++++ dhex_0.68.tar.gz -> dhex_0.69.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dhex_0.68/Makefile new/dhex_0.69/Makefile --- old/dhex_0.68/Makefile 2012-09-09 19:03:55.000000000 +0200 +++ new/dhex_0.69/Makefile 2019-01-19 17:17:37.000000000 +0100 @@ -1,7 +1,7 @@ CC= gcc LDFLAGS= -L/usr/lib -L/usr/local/lib -L/usr/lib/ncurses -L/usr/local/lib/ncurses CPPFLAGS= -I/usr/include -I/usr/local/include -I/usr/include/ncurses -I/usr/local/include/ncurses -CFLAGS= -O3 -Wall -std=c99 +CFLAGS= -O3 -Wall #-std=c99 #CFLAGS+= -ffunction-sections -fdata-sections #LDFLAGS+= --gc-sections LIBS= -lncurses diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dhex_0.68/README.txt new/dhex_0.69/README.txt --- old/dhex_0.68/README.txt 2012-09-09 19:03:55.000000000 +0200 +++ new/dhex_0.69/README.txt 2019-01-19 17:17:37.000000000 +0100 @@ -1,6 +1,6 @@ -----------------------------------------------------------------[ 0. Welcome ]- -Thank you for downloading dhex 0.67. It is a hex editor with a diff mode. +Thank you for downloading dhex 0.69. It is a hex editor with a diff mode. Since it is based on ncurses, it runs in any console. It makes heavy use of colors, but it is themeable to run on monochrome-displays as well. @@ -22,8 +22,9 @@ color themes were fixed 0.67: a "base address" functionality was added, which makes it easier to work with memory dumps. -0.68: slight bug fix as suggested by christoph: under some circumstances, the - opening of a file could segfault. +0.69: this will be the final release of dhex 0.6x. I fixed a bug which caused + the terminal to be broken. And added the functionality to start the + hexcal from the commandline (-x). ---------------------------------------------------------[ 1. Getting started ]- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dhex_0.68/configfile.c new/dhex_0.69/configfile.c --- old/dhex_0.68/configfile.c 2012-09-09 19:03:55.000000000 +0200 +++ new/dhex_0.69/configfile.c 2019-01-19 17:17:37.000000000 +0100 @@ -171,16 +171,17 @@ int readconfigfile(tOutput* output,char* filename) { tFptr f=fopen(filename,"rb"); - unsigned char line[512]; + char line[512]; unsigned char c; int lineidx=0; int keyboardcnt; + int n; if (!f) return 1; keyboardcnt=0; while (!feof(f)) { - fread(&c,sizeof(char),1,f); - if (!feof(f)) + n=fread(&c,sizeof(char),1,f); + if (n && !feof(f)) { if (c>='a' && c<='z') c-=32; // make everything uppercase if (c==9) c=32; // and whitespaces are all the same diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dhex_0.68/correlation.c new/dhex_0.69/correlation.c --- old/dhex_0.68/correlation.c 2012-09-09 19:03:55.000000000 +0200 +++ new/dhex_0.69/correlation.c 2019-01-19 17:17:37.000000000 +0100 @@ -178,7 +178,6 @@ WINDOW* smallwin=NULL; tBuffer* smallbuf; tBuffer* bigbuf; - tInt64 match; tBool found=0; @@ -207,7 +206,6 @@ for (pos1=-(tInt64)smallbuf->bufsize;pos1<(tInt64)bigbuf->bufsize && correlation->mindiff;pos1++) { diff=0; - match=0; if (smallwin) mvwprintw(smallwin,1,3,"%16lli",((tInt64)bigbuf->bufsize-pos1)); else fprintf(stderr,"%16lli\r",((tInt64)buf1->bufsize-pos1)); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dhex_0.68/datatypes.h new/dhex_0.69/datatypes.h --- old/dhex_0.68/datatypes.h 2012-09-09 19:03:55.000000000 +0200 +++ new/dhex_0.69/datatypes.h 2019-01-19 17:17:37.000000000 +0100 @@ -68,7 +68,7 @@ { tBool correlated; corr_algorithms algorithm; - tInt64 start_mindiff; + tUInt64 start_mindiff; tInt64 mindiff; tInt64 mindiffpos; tInt64 bestmatch; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dhex_0.68/dhex.1 new/dhex_0.69/dhex.1 --- old/dhex_0.68/dhex.1 2012-09-09 19:03:55.000000000 +0200 +++ new/dhex_0.69/dhex.1 2019-01-19 17:17:37.000000000 +0100 @@ -2,7 +2,7 @@ .\" groff -man -Tascii dhex.1 .\" . -.Dd May 12, 2012 +.Dd Jan 19, 2019 .Os .Dt DHEX 1 . @@ -15,6 +15,8 @@ .Sh SYNOPSIS . .Nm +.Op Fl x +.Nm .Op Fl h .Op Fl v .Op Fl g @@ -142,6 +144,8 @@ for a description of its file format. .It Fl g Shows the license +.It Fl x +Starts the hexcal .It Fl h Shows the help screen .It Fl k @@ -256,7 +260,9 @@ .Xr dhex_searchlog 5 describes the format of the searchlog. .Ss HexCal -Pressing F5 (or its substitute) will open a small 64 bit calculator. This calculator is capable of not only performing arithmetic operations (+, -, *, /, modulo), but also logic ones. (and, or, xor, shift). There are three columns to enter numbers as hexadecimals, decimals or in binary format. Pressing 'x' will close this screen. +Pressing F5 (or its substitute) will open a small 64 bit calculator. This calculator is capable of not only performing arithmetic operations (+, -, *, /, modulo), but also logic ones. (and, or, xor, shift). There are three columns to enter numbers as hexadecimals, decimals or in binary format. Pressing 'x' will close this screen. Using the command line argument +.Op Fl x +will start it from the commandline. .Ss Correlation When .Xr dhex 1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dhex_0.68/gpl.c new/dhex_0.69/gpl.c --- old/dhex_0.68/gpl.c 2012-09-09 19:03:55.000000000 +0200 +++ new/dhex_0.69/gpl.c 2019-01-19 17:17:37.000000000 +0100 @@ -3,8 +3,10 @@ void warte() { char b[2]; + void *ptr; fprintf(stderr,"...Please press <Enter> to read on..."); - fgets(b,sizeof(b),stdin); + ptr=fgets(b,sizeof(b),stdin); + if (ptr==NULL) fprintf(stderr,"\n"); } void print_gpl() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dhex_0.68/input.c new/dhex_0.69/input.c --- old/dhex_0.68/input.c 2012-09-09 19:03:55.000000000 +0200 +++ new/dhex_0.69/input.c 2019-01-19 17:17:37.000000000 +0100 @@ -69,7 +69,7 @@ lastch=ch; done=1; // a key was pressed } else { - usleep(1); + usleep(1000); donecnt=donecnt-partial; done=!donecnt; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dhex_0.68/main.c new/dhex_0.69/main.c --- old/dhex_0.68/main.c 2012-09-09 19:03:55.000000000 +0200 +++ new/dhex_0.69/main.c 2019-01-19 17:17:37.000000000 +0100 @@ -1,6 +1,6 @@ #define MAJORVERSION 0 #define MINORVERSION 6 -#define REVISION 8 +#define REVISION 9 #include <stdio.h> #include <stdlib.h> #include <strings.h> @@ -22,7 +22,7 @@ void welcomescreen(char* argv0) { fprintf(stderr,"*** DHEX %i.%i%i\n",MAJORVERSION,MINORVERSION,REVISION); - fprintf(stderr,"*** (C)opyleft 2012 by Thomas Dettbarn\n"); + fprintf(stderr,"*** (C)opyleft 2019 by Thomas Dettbarn\n"); fprintf(stderr,"*** det...@dettus.net (include DHEX somewhere in the subject)\n\n"); fprintf(stderr,"\n"); fprintf(stderr,"(start it with %s -gpl to see the license)\n",argv0); @@ -50,7 +50,7 @@ fprintf(stderr," -h, -H, -? show this help\n"); fprintf(stderr," -v, -V show the version number %i.%i%i\n",MAJORVERSION,MINORVERSION,REVISION); fprintf(stderr," -k, -K start the keyboard setup manually\n"); - //fprintf(stderr," -x, -X start the hexcalc program (TODO)\n"); + fprintf(stderr," -x, -X start the hexcalc program \n"); fprintf(stderr," -g, -G show the license\n"); fprintf(stderr," -f, -F [configfile] read the config from [configfile]\n"); fprintf(stderr," -m, -M [markerfile] read the bookmarks from [markerfile]\n"); @@ -130,7 +130,7 @@ return RETOK; } -int parsecommandlineoptions(int argc,char** argv,tInt64* baseaddr1,tInt64* baseaddr2,tInt64* cursorpos1,tInt64* cursorpos2,tBool* diffmode,int* filename1,int* filename2,tBool* keyboardsetupreq,char* markerfilename,char* configfile,tSearch* search1,tBool* gosearch1,tSearch* search2,tBool* gosearch2,tCorrelation* correlation,tBool* gocorr) +int parsecommandlineoptions(int argc,char** argv,tInt64* baseaddr1,tInt64* baseaddr2,tInt64* cursorpos1,tInt64* cursorpos2,tBool* diffmode,int* filename1,int* filename2,tBool* keyboardsetupreq,char* markerfilename,char* configfile,tSearch* search1,tBool* gosearch1,tSearch* search2,tBool* gosearch2,tCorrelation* correlation,tBool* gocorr,tBool* bhexcalc) { int filenamecnt=0; int i; @@ -138,6 +138,7 @@ char lastopt[8]; tBool moreopts=1; + *bhexcalc=0; *gosearch1=0; *gosearch2=0; *gocorr=0; @@ -176,14 +177,16 @@ exit(0); lastopt[0]=0; break; - case 'X': - case 'x': printf("TODO:hexcalc\n"); - break; case 'K': case 'k': *keyboardsetupreq=1; lastopt[0]=0; break; + case 'x': + case 'X': + *bhexcalc=1; + lastopt[0]=0; + break; case 'v': case 'V': printf("%i.%i%i\n",MAJORVERSION,MINORVERSION,REVISION); @@ -214,7 +217,6 @@ case 's': { tInt8 stringtype=0; // 0=unknown, 1=ascii, 2=hex - tBool forward=1; tSearch* search; tBool* gosearch; int j; @@ -225,7 +227,6 @@ { if (lastopt[j]=='a' || lastopt[j]=='A') stringtype=1; if (lastopt[j]=='h' || lastopt[j]=='H') stringtype=2; - if (lastopt[j]=='b' || lastopt[j]=='B') forward=0; if (lastopt[j]=='1') { search=search1; @@ -394,6 +395,7 @@ tBool diffmode=0; tBool keyboardsetupreq; tBool gocorr=0; + tBool bhexcalc=0; int retval; int ch; @@ -416,7 +418,7 @@ clearsearch(&search1); clearsearch(&search2); clear_correlation(&correlation); - if (parsecommandlineoptions(argc,argv,&baseaddr1,&baseaddr2,&cursorpos1,&cursorpos2,&diffmode,&filename1,&filename2,&keyboardsetupreq,markerfilename,configfile,&search1,&gosearch1,&search2,&gosearch2,&correlation,&gocorr)!=RETOK) + if (parsecommandlineoptions(argc,argv,&baseaddr1,&baseaddr2,&cursorpos1,&cursorpos2,&diffmode,&filename1,&filename2,&keyboardsetupreq,markerfilename,configfile,&search1,&gosearch1,&search2,&gosearch2,&correlation,&gocorr,&bhexcalc)!=RETOK) { if (output) { @@ -454,7 +456,7 @@ } - if (filename1==-1 || (filename2==-1 && diffmode)) helpscreen(argv[0],0); + if ((filename1==-1 || (filename2==-1 && diffmode)) && !bhexcalc) helpscreen(argv[0],0); retval=readconfigfile(output,configfile); if (retval==1) // config file did not exists. creating one { @@ -493,32 +495,35 @@ hHexCalc=malloc(sizeof(thHexCalc)); memset(hHexCalc,0,sizeof(thHexCalc)); - buf1=malloc(sizeof(tBuffer)); - memset(buf1,0,sizeof(tBuffer)); - buf1->baseaddr=baseaddr1; - if (diffmode) + if (!bhexcalc) { - buf2=malloc(sizeof(tBuffer)); - memset(buf2,0,sizeof(tBuffer)); - buf2->baseaddr=baseaddr2; - } + buf1=malloc(sizeof(tBuffer)); + memset(buf1,0,sizeof(tBuffer)); + buf1->baseaddr=baseaddr1; + if (diffmode) + { + buf2=malloc(sizeof(tBuffer)); + memset(buf2,0,sizeof(tBuffer)); + buf2->baseaddr=baseaddr2; + } - if (openbuf(buf1,1,argv[filename1])!=RETOK) - { - fprintf(stderr,"error opening inputfile %s\n",argv[filename1]); - exit(1); - } - if (diffmode) if (openbuf(buf2,2,argv[filename2])!=RETOK) - { - fprintf(stderr,"error opening second inputfile %s\n",argv[filename2]); - exit(1); - } - if (gosearch1) searchfor(&search1,buf1,&cursorpos1,1); - if (gosearch2 && diffmode) searchfor(&search2,buf2,&cursorpos2,1); - if (gocorr && diffmode) - { - fprintf(stderr,"correlating...\n"); - find_correlation(NULL,&correlation,buf1,buf2,&cursorpos1,&cursorpos2); + if (openbuf(buf1,1,argv[filename1])!=RETOK) + { + fprintf(stderr,"error opening inputfile %s\n",argv[filename1]); + exit(1); + } + if (diffmode) if (openbuf(buf2,2,argv[filename2])!=RETOK) + { + fprintf(stderr,"error opening second inputfile %s\n",argv[filename2]); + exit(1); + } + if (gosearch1) searchfor(&search1,buf1,&cursorpos1,1); + if (gosearch2 && diffmode) searchfor(&search2,buf2,&cursorpos2,1); + if (gocorr && diffmode) + { + fprintf(stderr,"correlating...\n"); + find_correlation(NULL,&correlation,buf1,buf2,&cursorpos1,&cursorpos2); + } } if (!(gosearch1 && search1.writesearchlog) || (diffmode && !(gosearch2 && search2.writesearchlog))) { @@ -527,221 +532,227 @@ noecho(); nodelay(output->win,1); if (keyboardsetupreq) keyboardsetup(output,configfile); - readbuf(buf1,0); - firstpos1=cursorpos1; - firstpos2=cursorpos2; - ch=0; - while (ch!=KEYF10) - { - printmainmenu(output,diffmode); - if (diffmode) - printbufferdiff(output,buf1,buf2,cursorpos1,cursorpos2); - else - printbuffersingle(output,buf1,cursorpos1,firstpos1,windowfield); - ch=getkey((tKeyTab*)output->pKeyTab,1); + if (bhexcalc) + { + hexcalc(output,hHexCalc); + } else { + readbuf(buf1,0); + firstpos1=cursorpos1; + firstpos2=cursorpos2; + ch=0; + while (ch!=KEYF10) + { + printmainmenu(output,diffmode); + if (diffmode) + printbufferdiff(output,buf1,buf2,cursorpos1,cursorpos2); + else + printbuffersingle(output,buf1,cursorpos1,firstpos1,windowfield); + ch=getkey((tKeyTab*)output->pKeyTab,1); #define MOVEMENTDEFINE(KEY,VIKEY,mvchar,mvline,mvpage) \ - if (ch==KEY || (VIKEY && ch==VIKEY && windowfield==0)) \ - { \ - tInt32 err; \ - oldfirstpos1=firstpos1; \ - oldcursorpos1=cursorpos1; \ - oldfirstpos2=firstpos2; \ - oldcursorpos2=cursorpos2; \ - \ - err=movepositions(&cursorpos1,&firstpos1,buf1->bufsize,mvchar,mvline,mvpage,diffmode); \ - \ - if (diffmode) \ + if (ch==KEY || (VIKEY && ch==VIKEY && windowfield==0)) \ { \ - movepositions(&cursorpos2,&firstpos2,buf2->bufsize,mvchar,mvline,mvpage,diffmode); \ - err=((cursorpos1<0 && cursorpos2<0) || (cursorpos1>buf1->bufsize && cursorpos2>buf2->bufsize)); \ - } \ - if (err) \ - { \ - firstpos1=oldfirstpos1; \ - cursorpos1=oldcursorpos1; \ - firstpos2=oldfirstpos2; \ - cursorpos2=oldcursorpos2; \ - } \ - } - MOVEMENTDEFINE(KEYRIGHT,'l' , 1, 0, 0); - MOVEMENTDEFINE(KEYLEFT,'h' ,-1, 0, 0); - MOVEMENTDEFINE(KEYDOWN,'j' , 0, 1, 0); - MOVEMENTDEFINE(KEYUP,'k' , 0,-1, 0); - MOVEMENTDEFINE(KEYPGDOWN,' ' , 0, 0, 1); - MOVEMENTDEFINE(KEYPGUP,0 , 0, 0,-1); + tInt32 err; \ + oldfirstpos1=firstpos1; \ + oldcursorpos1=cursorpos1; \ + oldfirstpos2=firstpos2; \ + oldcursorpos2=cursorpos2; \ + \ + err=movepositions(&cursorpos1,&firstpos1,buf1->bufsize,mvchar,mvline,mvpage,diffmode); \ + \ + if (diffmode) \ + { \ + movepositions(&cursorpos2,&firstpos2,buf2->bufsize,mvchar,mvline,mvpage,diffmode); \ + err=((cursorpos1<0 && cursorpos2<0) || (cursorpos1>buf1->bufsize && cursorpos2>buf2->bufsize)); \ + } \ + if (err) \ + { \ + firstpos1=oldfirstpos1; \ + cursorpos1=oldcursorpos1; \ + firstpos2=oldfirstpos2; \ + cursorpos2=oldcursorpos2; \ + } \ + } + MOVEMENTDEFINE(KEYRIGHT,'l' , 1, 0, 0); + MOVEMENTDEFINE(KEYLEFT,'h' ,-1, 0, 0); + MOVEMENTDEFINE(KEYDOWN,'j' , 0, 1, 0); + MOVEMENTDEFINE(KEYUP,'k' , 0,-1, 0); + MOVEMENTDEFINE(KEYPGDOWN,' ' , 0, 0, 1); + MOVEMENTDEFINE(KEYPGUP,0 , 0, 0,-1); #undef MOVEMENTDEFINE - if (ch==KEYHOME || (ch=='^' && windowfield==0)) - { - if (diffmode) + if (ch==KEYHOME || (ch=='^' && windowfield==0)) { - tInt64 dmin,dmax; - - dmin=MIN(cursorpos1,cursorpos2); - dmax=MAX(cursorpos1,cursorpos2); - if (dmin==0) + if (diffmode) { - cursorpos1-=dmax; - cursorpos2-=dmax; + tInt64 dmin,dmax; + + dmin=MIN(cursorpos1,cursorpos2); + dmax=MAX(cursorpos1,cursorpos2); + if (dmin==0) + { + cursorpos1-=dmax; + cursorpos2-=dmax; + } else { + cursorpos1-=dmin; + cursorpos2-=dmin; + } + firstpos1=cursorpos1; + firstpos2=cursorpos2; + } else { - cursorpos1-=dmin; - cursorpos2-=dmin; + firstpos1=cursorpos1=0; } - firstpos1=cursorpos1; - firstpos2=cursorpos2; - - } else { - firstpos1=cursorpos1=0; } - } - if (ch==KEYEND || (ch=='$' && windowfield==0)) - { - if (diffmode) + if (ch==KEYEND || (ch=='$' && windowfield==0)) { - tInt64 dmin,dmax; - dmin=MIN(buf1->bufsize-cursorpos1,buf2->bufsize-cursorpos2); - dmax=MAX(buf1->bufsize-cursorpos1,buf2->bufsize-cursorpos2); - - if (dmin==0) + if (diffmode) { + tInt64 dmin,dmax; + dmin=MIN(buf1->bufsize-cursorpos1,buf2->bufsize-cursorpos2); + dmax=MAX(buf1->bufsize-cursorpos1,buf2->bufsize-cursorpos2); + + if (dmin==0) + { - cursorpos2+=dmax; - cursorpos1+=dmax; + cursorpos2+=dmax; + cursorpos1+=dmax; + } else { + cursorpos1+=dmin; + cursorpos2+=dmin; + } } else { - cursorpos1+=dmin; - cursorpos2+=dmin; + firstpos1=cursorpos1=buf1->bufsize; } - } else { - firstpos1=cursorpos1=buf1->bufsize; } - } - if (ch==KEYTAB) {windowfield=(windowfield+1)&1;} - if ((ch==KEYF1 || (ch==':' && windowfield==0))&& !diffmode) { - if (gotomask(output,markers,&cursorpos1,buf1->baseaddr)==RETOK) + if (ch==KEYTAB) {windowfield=(windowfield+1)&1;} + if ((ch==KEYF1 || (ch==':' && windowfield==0))&& !diffmode) { + if (gotomask(output,markers,&cursorpos1,buf1->baseaddr)==RETOK) + { + firstpos1=cursorpos1; + } + } + if ((ch==KEYF2 || ((ch=='/' || ch=='?') && (windowfield==0))) && !diffmode) { - firstpos1=cursorpos1; + if (ch=='/') search1.forwardnotbackward=1; // / means forward + if (ch=='?') search1.forwardnotbackward=0; // ? means backward + searchmask(output,&search1,buf1,&cursorpos1); + firstpos1=cursorpos1; } - } - if ((ch==KEYF2 || ((ch=='/' || ch=='?') && (windowfield==0))) && !diffmode) - { - if (ch=='/') search1.forwardnotbackward=1; // / means forward - if (ch=='?') search1.forwardnotbackward=0; // ? means backward - searchmask(output,&search1,buf1,&cursorpos1); - firstpos1=cursorpos1; - } - if (ch==KEYF3 || ch==KEYF4 || (windowfield==0 && (ch=='n' || ch=='N'))) - { - if (ch=='n') ch=KEYF3; // n=next - if (ch=='N') ch=KEYF4; // N=previous - if (diffmode) + if (ch==KEYF3 || ch==KEYF4 || (windowfield==0 && (ch=='n' || ch=='N'))) { - tInt64 actcursorpos1=cursorpos1; - tInt64 actcursorpos2=cursorpos2; - tInt32 idx1,idx2; - tBool found; - tBool diffnotdiff; - tUInt64 minbufsize=(buf1->bufsize<buf2->bufsize)?buf1->bufsize:buf2->bufsize; // get the minimum of the filesizes - tUInt64 searchcnt=minbufsize; - - oldcursorpos1=cursorpos1; - oldcursorpos2=cursorpos2; - actcursorpos1=actcursorpos1+((ch==KEYF3)?1:-1); // F3: next, F4:prev - actcursorpos2=actcursorpos2+((ch==KEYF3)?1:-1); // F3: next, F4:prev - found=(!minbufsize); - idx1=getbufferidx(buf1,actcursorpos1); - idx2=getbufferidx(buf2,actcursorpos2); - diffnotdiff=(buf1->data[idx1]!=buf2->data[idx2]); // if the cursor is on something which is a diff, look for the next time the values are the same - while (actcursorpos1!=oldcursorpos1 && actcursorpos2!=oldcursorpos2 && searchcnt && !found) + if (ch=='n') ch=KEYF3; // n=next + if (ch=='N') ch=KEYF4; // N=previous + if (diffmode) { + tInt64 actcursorpos1=cursorpos1; + tInt64 actcursorpos2=cursorpos2; + tInt32 idx1,idx2; + tBool found; + tBool diffnotdiff; + tUInt64 minbufsize=(buf1->bufsize<buf2->bufsize)?buf1->bufsize:buf2->bufsize; // get the minimum of the filesizes + tUInt64 searchcnt=minbufsize; + + oldcursorpos1=cursorpos1; + oldcursorpos2=cursorpos2; + actcursorpos1=actcursorpos1+((ch==KEYF3)?1:-1); // F3: next, F4:prev + actcursorpos2=actcursorpos2+((ch==KEYF3)?1:-1); // F3: next, F4:prev + found=(!minbufsize); idx1=getbufferidx(buf1,actcursorpos1); idx2=getbufferidx(buf2,actcursorpos2); - if ((buf1->data[idx1]!=buf2->data[idx2]) != diffnotdiff) found=1; - else { - actcursorpos1=actcursorpos1+((ch==KEYF3)?1:-1); // F3: next, F4:prev - actcursorpos2=actcursorpos2+((ch==KEYF3)?1:-1); // F3: next, F4:prev - } - if (actcursorpos1<0 || actcursorpos2<0) + diffnotdiff=(buf1->data[idx1]!=buf2->data[idx2]); // if the cursor is on something which is a diff, look for the next time the values are the same + while (actcursorpos1!=oldcursorpos1 && actcursorpos2!=oldcursorpos2 && searchcnt && !found) { - actcursorpos1+=minbufsize; // start at the end of the smallest file - actcursorpos2+=minbufsize; // start at the end of the smallest file + idx1=getbufferidx(buf1,actcursorpos1); + idx2=getbufferidx(buf2,actcursorpos2); + if ((buf1->data[idx1]!=buf2->data[idx2]) != diffnotdiff) found=1; + else { + actcursorpos1=actcursorpos1+((ch==KEYF3)?1:-1); // F3: next, F4:prev + actcursorpos2=actcursorpos2+((ch==KEYF3)?1:-1); // F3: next, F4:prev + } + if (actcursorpos1<0 || actcursorpos2<0) + { + actcursorpos1+=minbufsize; // start at the end of the smallest file + actcursorpos2+=minbufsize; // start at the end of the smallest file + } + if (actcursorpos1>=minbufsize && actcursorpos2>=minbufsize) + { + actcursorpos1-=minbufsize; // if you are at the end of the smallest file, start at the beginning + actcursorpos2-=minbufsize; // if you are at the end of the smallest file, start at the beginning + } + searchcnt--; } - if (actcursorpos1>=minbufsize && actcursorpos2>=minbufsize) + if (found) { - actcursorpos1-=minbufsize; // if you are at the end of the smallest file, start at the beginning - actcursorpos2-=minbufsize; // if you are at the end of the smallest file, start at the beginning + cursorpos1=actcursorpos1; + cursorpos2=actcursorpos2; } - searchcnt--; - } - if (found) + } + else if (search1.occurancesfound) { - cursorpos1=actcursorpos1; - cursorpos2=actcursorpos2; + searchfor(&search1,buf1,&cursorpos1,(ch==KEYF3)); // f3: next + firstpos1=cursorpos1; } - } - else if (search1.occurancesfound) + } + if (ch==KEYF5) hexcalc(output,hHexCalc); + if (ch==KEYF6 && diffmode) { - searchfor(&search1,buf1,&cursorpos1,(ch==KEYF3)); // f3: next - firstpos1=cursorpos1; - } - } - if (ch==KEYF5) hexcalc(output,hHexCalc); - if (ch==KEYF6 && diffmode) - { - correlation.start_mindiff=MIN(buf1->bufsize,buf2->bufsize); - if (correlationmask(output,&correlation)==RETOK) - { - find_correlation(output,&correlation,buf1,buf2,&cursorpos1,&cursorpos2); + correlation.start_mindiff=MIN(buf1->bufsize,buf2->bufsize); + if (correlationmask(output,&correlation)==RETOK) + { + find_correlation(output,&correlation,buf1,buf2,&cursorpos1,&cursorpos2); + } } - } - if ((ch==KEYF9 || (ch=='u' && windowfield==0)) && !diffmode) - { - if (buf1->changesnum) + if ((ch==KEYF9 || (ch=='u' && windowfield==0)) && !diffmode) { - if ((buf1->changes[buf1->changesnum].pos==(buf1->bufsize-1) && (buf1->filesize<=buf1->changes[buf1->changesnum].pos))) buf1->bufsize--; // if this was the last byte in the buffer, decrease its size - cursorpos1=buf1->changes[--buf1->changesnum].pos; - if (cursorpos1<firstpos1) firstpos1=cursorpos1; - if ((firstpos1+100)>cursorpos1) firstpos1=cursorpos1; // TODO: 100 depends on the size of the window - } + if (buf1->changesnum) + { + if ((buf1->changes[buf1->changesnum].pos==(buf1->bufsize-1) && (buf1->filesize<=buf1->changes[buf1->changesnum].pos))) buf1->bufsize--; // if this was the last byte in the buffer, decrease its size + cursorpos1=buf1->changes[--buf1->changesnum].pos; + if (cursorpos1<firstpos1) firstpos1=cursorpos1; + if ((firstpos1+100)>cursorpos1) firstpos1=cursorpos1; // TODO: 100 depends on the size of the window + } - } - if (buf1->changesnum<CHANGEBUFSIZE-1 && !diffmode) - { - if (((ch>='0' && ch<='9') || (ch>='a' && ch<='f') || (ch>='A' && ch<='F')) && windowfield==0) + } + if (buf1->changesnum<CHANGEBUFSIZE-1 && !diffmode) { - buf1->nexthex<<=4; - if (ch>='a') ch-=32; - buf1->nexthex|=((ch>='A')?(ch-'A'+10):(ch-'0')); - if (buf1->nibble) + if (((ch>='0' && ch<='9') || (ch>='a' && ch<='f') || (ch>='A' && ch<='F')) && windowfield==0) + { + buf1->nexthex<<=4; + if (ch>='a') ch-=32; + buf1->nexthex|=((ch>='A')?(ch-'A'+10):(ch-'0')); + if (buf1->nibble) + { + if (cursorpos1==buf1->bufsize) buf1->bufsize++; // append the byte at the end + buf1->changes[buf1->changesnum].pos=cursorpos1; + buf1->changes[buf1->changesnum].after=buf1->nexthex; + buf1->changesnum++; + movepositions(&cursorpos1,&firstpos1,buf1->bufsize,1,0,0,diffmode); + } + buf1->nibble=!buf1->nibble; + buf1->changepos=cursorpos1; + } else buf1->nibble=0; + if (ch>=32 && ch<127 && windowfield==1) { if (cursorpos1==buf1->bufsize) buf1->bufsize++; // append the byte at the end buf1->changes[buf1->changesnum].pos=cursorpos1; - buf1->changes[buf1->changesnum].after=buf1->nexthex; + buf1->changes[buf1->changesnum].after=ch; buf1->changesnum++; movepositions(&cursorpos1,&firstpos1,buf1->bufsize,1,0,0,diffmode); } - buf1->nibble=!buf1->nibble; - buf1->changepos=cursorpos1; - } else buf1->nibble=0; - if (ch>=32 && ch<127 && windowfield==1) - { - if (cursorpos1==buf1->bufsize) buf1->bufsize++; // append the byte at the end - buf1->changes[buf1->changesnum].pos=cursorpos1; - buf1->changes[buf1->changesnum].after=ch; - buf1->changesnum++; - movepositions(&cursorpos1,&firstpos1,buf1->bufsize,1,0,0,diffmode); } - } - if (ch==KEYF10) - { - if (buf1->changesnum) if (savedialog(output,buf1)!=RETOK) + if (ch==KEYF10) { - ch=0; + if (buf1->changesnum) if (savedialog(output,buf1)!=RETOK) + { + ch=0; + } } } } if (output) { + if (output->win) endwin(); if (output->pKeyTab) free(output->pKeyTab); free(output); } @@ -749,7 +760,6 @@ if (buf2) free(buf2); if (hHexCalc) free(hHexCalc); if (markers) free(markers); - if (output->win) endwin(); welcomescreen(argv[0]); } else { if (gosearch1) fprintf(stderr,"%lli occurances found in %s\n",search1.occurancesfound,buf1->filename); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dhex_0.68/markers.c new/dhex_0.69/markers.c --- old/dhex_0.68/markers.c 2012-09-09 19:03:55.000000000 +0200 +++ new/dhex_0.69/markers.c 2019-01-19 17:17:37.000000000 +0100 @@ -32,14 +32,15 @@ // 2=reading in number // 3=end of line tBool hadnumber=0; + int n; tmp=initmarkers(); f=fopen(filename,"r"); if (!f) return RETNOK; while (!feof(f) && markersnum<10) { - fread(&c,sizeof(char),1,f); + n=fread(&c,sizeof(char),1,f); if (c>='a' && c<='z') c=c-32; // make the letters uppercase - if (!feof(f) && c!=' ' && c!=9) // ignore the spaces + if (n && !feof(f) && c!=' ' && c!=9) // ignore the spaces { if (c=='#') state=3; // the rest of this line is just a comment if (c<32) // newline @@ -95,7 +96,7 @@ fclose(f); return RETOK; } -tInt8 gotomask(tOutput* output,tMarkers* markers,tUInt64* cursorpos,tInt64 baseaddr) +tInt8 gotomask(tOutput* output,tMarkers* markers,tInt64* cursorpos,tInt64 baseaddr) { tUInt64 actcursorpos=*cursorpos+baseaddr; tUInt64 newcursorpos=*cursorpos+baseaddr; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dhex_0.68/markers.h new/dhex_0.69/markers.h --- old/dhex_0.68/markers.h 2012-09-09 19:03:55.000000000 +0200 +++ new/dhex_0.69/markers.h 2019-01-19 17:17:37.000000000 +0100 @@ -6,7 +6,7 @@ void* initmarkers(); int parsemarkerfile(tMarkers* markers,char* filename); -tInt8 gotomask(tOutput* output,tMarkers* markers,tUInt64* cursorpos,tInt64 baseaddr); +tInt8 gotomask(tOutput* output,tMarkers* markers,tInt64* cursorpos,tInt64 baseaddr); #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dhex_0.68/menu.c new/dhex_0.69/menu.c --- old/dhex_0.68/menu.c 2012-09-09 19:03:55.000000000 +0200 +++ new/dhex_0.69/menu.c 2019-01-19 17:17:37.000000000 +0100 @@ -219,7 +219,6 @@ { tInt16 ch; int i; - tInt8 retval; ch=0; printMenu(output,Menu,offsy,offsx); @@ -233,7 +232,6 @@ case KEYUP: MenuMoveUp(Menu); break; case KEYDOWN: MenuMoveDown(Menu); break; case KEYTAB: Menu->menuitemactive=(Menu->menuitemactive+1)%Menu->menuitemnum;break; - case KEYENTER: retval=Menu->menuitemactive; break; default: if (ch>=' ' && ch<127) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dhex_0.68/mkrelease.sh new/dhex_0.69/mkrelease.sh --- old/dhex_0.68/mkrelease.sh 2012-09-09 19:03:55.000000000 +0200 +++ new/dhex_0.69/mkrelease.sh 2019-01-19 17:17:37.000000000 +0100 @@ -1,4 +1,4 @@ -mkdir dhex_0.68 +mkdir dhex_0.69 for I in `echo " Makefile buffers.c @@ -37,11 +37,11 @@ dhex_searchlog.5 mkrelease.sh" | sort -f` do - cp $I dhex_0.68/ + cp $I dhex_0.69/ done -( cd dhex_0.68/ && make && ./dhex -v && make clean && cd .. && \ -tar cvfz dhex_0.68.tar.gz dhex_0.68 ) -cp dhex_0.68.tar.gz dhex_latest.tar.gz -md5sum dhex_0.68.tar.gz +( cd dhex_0.69/ && make -j && ./dhex -v && make clean && cd .. && \ +tar cvfz dhex_0.69.tar.gz dhex_0.69 ) +cp dhex_0.69.tar.gz dhex_latest.tar.gz +md5sum dhex_0.69.tar.gz md5sum dhex_latest.tar.gz diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dhex_0.68/output.c new/dhex_0.69/output.c --- old/dhex_0.68/output.c 2012-09-09 19:03:55.000000000 +0200 +++ new/dhex_0.69/output.c 2019-01-19 17:17:37.000000000 +0100 @@ -87,7 +87,6 @@ int addrwidth; int bytesperline; tInt32 intpos1; - tInt32 charcnt; @@ -120,7 +119,6 @@ intpos1=getbufferidx(hBuf1,firstpos1); if (intpos1>=0) { - charcnt=0; for (i=0;i<LINES-2;i++) { tBool colhex; @@ -202,7 +200,6 @@ tInt32 intpos1b; tInt32 intpos2; tInt32 intpos2b; - tInt32 charcnt; uicolors oldcolor; @@ -263,7 +260,6 @@ } if (intpos1>=0 || intpos2>=0) { - charcnt=0; intpos1b=intpos1; intpos2b=intpos2; @@ -407,7 +403,7 @@ { int i; int x; - unsigned char* menutextsnodiff[]={ + char* menutextsnodiff[]={ "Goto ", // F1 "Search", // F2 "Next ", // F3 @@ -419,7 +415,7 @@ "Undo ", // F9 "Quit "}; // F10 - unsigned char* menutextsdiff[]={ + char* menutextsdiff[]={ " ", // F1 " ", // F2 "Next ", // F3 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dhex_0.68/search.c new/dhex_0.69/search.c --- old/dhex_0.68/search.c 2012-09-09 19:03:55.000000000 +0200 +++ new/dhex_0.69/search.c 2019-01-19 17:17:37.000000000 +0100 @@ -11,7 +11,7 @@ memset(search,0,sizeof(tSearch)); search->forwardnotbackward=1; } -tInt8 searchfor(tSearch* search,tBuffer* buf,tUInt64* cursorpos,tBool nextnotprev) +tInt8 searchfor(tSearch* search,tBuffer* buf,tInt64* cursorpos,tBool nextnotprev) { tInt64 actcursorpos=*cursorpos; tInt64 oldcursorpos=*cursorpos; @@ -77,9 +77,8 @@ // state 2: read until the end of the line tUInt64 x=0; tBool havenum; - tInt64 firstsearchlogpos; + int n; - firstsearchlogpos=search->lastsearchlogpos; setfilepos(frlog,search->lastsearchlogpos); havenum=0; @@ -90,9 +89,9 @@ state=0; while (c>=32 && !done) { - fread(&c,sizeof(char),1,frlog); + n=fread(&c,sizeof(char),1,frlog); done=feof(frlog); - if (!done) + if (!done && n) { if (c=='#') state=2; if (c>='a' && c<='z') c-=32; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dhex_0.68/search.h new/dhex_0.69/search.h --- old/dhex_0.68/search.h 2012-09-09 19:03:55.000000000 +0200 +++ new/dhex_0.69/search.h 2019-01-19 17:17:37.000000000 +0100 @@ -5,6 +5,6 @@ #include "datatypes.h" void clearsearch(tSearch* search); -tInt8 searchfor(tSearch* search,tBuffer* buf,tUInt64* cursorpos,tBool nextnotprev); +tInt8 searchfor(tSearch* search,tBuffer* buf,tInt64* cursorpos,tBool nextnotprev); #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dhex_0.68/ui.c new/dhex_0.69/ui.c --- old/dhex_0.68/ui.c 2012-09-09 19:03:55.000000000 +0200 +++ new/dhex_0.69/ui.c 2019-01-19 17:17:37.000000000 +0100 @@ -10,7 +10,7 @@ #include "search.h" #include "correlation.h" -void searchmask(tOutput* output,tSearch* search,tBuffer* buf,tUInt64* cursorpos) +void searchmask(tOutput* output,tSearch* search,tBuffer* buf,tInt64* cursorpos) { tInt8 itemnums[10]; tMenu Menu1; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dhex_0.68/ui.h new/dhex_0.69/ui.h --- old/dhex_0.68/ui.h 2012-09-09 19:03:55.000000000 +0200 +++ new/dhex_0.69/ui.h 2019-01-19 17:17:37.000000000 +0100 @@ -5,7 +5,7 @@ #include "search.h" #include "output.h" #include "correlation.h" -void searchmask(tOutput* output,tSearch* search,tBuffer* buf,tUInt64* cursorpos); +void searchmask(tOutput* output,tSearch* search,tBuffer* buf,tInt64* cursorpos); tInt8 savedialog(tOutput* output,tBuffer* buf); tInt8 correlationmask(tOutput* output,tCorrelation* correlation); #endif