From 9f5e0b87eab6d104b9a234274598106552497608 Mon Sep 17 00:00:00 2001
From: Sebastião Guerra <sebastiao.luiz.guerra@gmail.com>
Date: Sat, 14 Nov 2026 07:12:09 -0300
Subject: KFax/KFaxview: Replace NULL pointer constants with nullptr
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Replace NULL pointer constants with nullptr

Signed-off-by: Sebastião Guerra <sebastiao.luiz.guerra@gmail.com>
---
 kfax/faxinput.cpp                   | 42 ++++++++++++++++++-------------------
 kfax/kfax.cpp                       | 28 ++++++++++++-------------
 kfaxview/libkfaximage/kfaximage.cpp | 26 +++++++++++------------
 3 files changed, 48 insertions(+), 48 deletions(-)

diff --git a/kfax/faxinput.cpp b/kfax/faxinput.cpp
index b70dc40f..7d11e9ed 100644
--- a/kfax/faxinput.cpp
+++ b/kfax/faxinput.cpp
@@ -44,13 +44,13 @@ notefile(const char *name, int type)
     struct pagenode *newnode = (struct pagenode *) xmalloc(sizeof *newnode);
 
     *newnode = defaultpage;
-    if (firstpage == NULL){
+    if (!firstpage){
 	firstpage = newnode;
 	auxpage = firstpage;
     }
     newnode->prev = lastpage;
-    newnode->next = NULL;
-    if (lastpage != NULL)
+    newnode->next = nullptr;
+    if (lastpage)
 	lastpage->next = newnode;
     lastpage = newnode;
 
@@ -67,7 +67,7 @@ notefile(const char *name, int type)
     newnode->type = type;
 
 
-    if ((newnode->name = strrchr(newnode->pathname, '/')) != NULL)
+    if ((newnode->name = strrchr(newnode->pathname, '/')))
 	newnode->name++;
     else
 	newnode->name = newnode->pathname;
@@ -76,7 +76,7 @@ notefile(const char *name, int type)
 	newnode->width = 1728;
     if (newnode->vres < 0)
 	newnode->vres = !(newnode->name[0] == 'f' && newnode->name[1] == 'n');
-    newnode->extra = NULL;
+    newnode->extra = nullptr;
 
     return newnode;
 }
@@ -105,11 +105,11 @@ notetiff(const char *name)
     static const char bigTIFF[5] = "\x4d\x4d\x00\x2a";
     int endian;
     t32bits IFDoff;
-    struct pagenode *pn = NULL;
+    struct pagenode *pn = nullptr;
     TQString str;
 
 
-    if ((tf = fopen(name, "r")) == NULL) {
+    if (!(tf = fopen(name, "r"))) {
         TQString mesg = i18n("Unable to open:\n%1\n").arg(TQFile::decodeName(name));
 	kfaxerror(i18n("Sorry"), mesg);
 	return 0;
@@ -132,7 +132,7 @@ notetiff(const char *name)
 	goto nottiff;
     do {			/* for each page */
 	unsigned char buf[8];
-	unsigned char *dir = NULL , *dp = NULL;
+	unsigned char *dir = nullptr , *dp = nullptr;
 	int ndirent;
 	pixnum iwidth = defaultpage.width ? defaultpage.width : 1728;
 	pixnum iheight = defaultpage.height ? defaultpage.height : 2339;
@@ -141,7 +141,7 @@ notetiff(const char *name)
 	int t4opt = 0, comp = 0;
 	int orient = defaultpage.orient;
 	double yres = defaultpage.vres ? 196.0 : 98.0;
-	struct strip *strips = NULL;
+	struct strip *strips = nullptr;
 	unsigned long rowsperstrip = 0;
 	t32bits nstrips = 1;
 
@@ -288,7 +288,7 @@ notetiff(const char *name)
 	}
 	IFDoff = get4(dp, endian);
 	free(dir);
-	dir = NULL;
+	dir = nullptr;
 	if (comp == 5) {
           // compression type 5 is LZW compression
 	  kfaxerror(i18n("Sorry"),i18n("Due to patent reasons KFax can not handle LZW (Lempel-Ziv & Welch) "
@@ -329,13 +329,13 @@ badfile(struct pagenode *pn)
     if (errno)
 	perror(pn->pathname);
     if (pn == firstpage) {
-      if (pn->next == NULL){
+      if (!pn->next){
 	  kfaxerror(i18n("Sorry"),i18n("Bad Fax File"));
 	  return;
       }
       else{
 	firstpage = thispage = firstpage->next;
-	firstpage->prev = NULL;
+	firstpage->prev = nullptr;
       }
     }
     else
@@ -348,7 +348,7 @@ badfile(struct pagenode *pn)
 		break;
 	    }
     if (pn) free(pn);
-    pn = NULL;
+    pn = nullptr;
 }
 
 /* rearrange input bits into t16bits lsb-first chunks */
@@ -402,14 +402,14 @@ getstrip(struct pagenode *pn, int strip)
     so.s = 1;
     if ((fd = open(pn->pathname, O_RDONLY, 0)) < 0) {
 	badfile(pn);
-	return NULL;
+	return nullptr;
     }
 
-    if (pn->strips == NULL) {
+    if (!pn->strips) {
 	if (fstat(fd, &sbuf) != 0) {
 	    close(fd);
 	    badfile(pn);
-	    return NULL;
+	    return nullptr;
 	}
 	offset = 0;
 	pn->length = sbuf.st_size;
@@ -421,7 +421,7 @@ getstrip(struct pagenode *pn, int strip)
     else {
       str = i18n("Trying to expand too many strips\n%1%n").arg(TQFile::decodeName(pn->pathname));
       kfaxerror(i18n("Warning"),str);
-      return NULL;
+      return nullptr;
     }
 
     /* round size to full boundary plus t32bits */
@@ -439,12 +439,12 @@ getstrip(struct pagenode *pn, int strip)
 	badfile(pn);
 	free(Data);
 	close(fd);
-	return NULL;
+	return nullptr;
     }
     close(fd);
 
     pn->data = (t16bits *) Data;
-    if (pn->strips == NULL && memcmp(Data, FAXMAGIC, sizeof(FAXMAGIC)) == 0) {
+    if (!pn->strips && memcmp(Data, FAXMAGIC, sizeof(FAXMAGIC)) == 0) {
 	/* handle ghostscript / PC Research fax file */
       if (Data[24] != 1 || Data[25] != 0){
 	str = i18n("Only the first page of the PC Research multipage file\n%1\nwill be shown\n")
@@ -467,9 +467,9 @@ getstrip(struct pagenode *pn, int strip)
       errno = 0;
       badfile(pn);
       free(Data);
-      return NULL;
+      return nullptr;
     }
-    if (pn->strips == NULL)
+    if (!pn->strips)
 	pn->rowsperstrip = pn->height;
     if (verbose && strip == 0)
 	kdWarning() << pn->name << "\n\twidth = " << pn->width << "\n\theight = "
diff --git a/kfax/kfax.cpp b/kfax/kfax.cpp
index 0388c05e..d48d35b3 100644
--- a/kfax/kfax.cpp
+++ b/kfax/kfax.cpp
@@ -442,7 +442,7 @@ static void freeImages()
   for (i = 1; i < MAXZOOM; i++) {
     if (Images[i])
 	FreeImage(Images[i]);
-    Images[i] = NULL;
+    Images[i] = nullptr;
   }
 }
 
@@ -453,7 +453,7 @@ static XImage *generateZoomImages(int maxzoom)
     if (!Images[i-1])
 	continue;
     Image = Images[i] = ZoomImage(Images[i-1]);
-    if(Image == NULL){// out of memory
+    if(!Image){// out of memory
       Image = Images[i -1];
       break;
     }
@@ -762,7 +762,7 @@ void TopLevel::printIt( KPrinter &printer, TQPainter &painter )
       }
     }
 
-    TQImage image( (uchar *)bytes.data(), Image->bytes_per_line*8, Image->height, 1, NULL, 2, TQImage::LittleEndian);
+    TQImage image( (uchar *)bytes.data(), Image->bytes_per_line*8, Image->height, 1, nullptr, 2, TQImage::LittleEndian);
 
     if (first_page_printed)
 	printer.newPage();
@@ -903,7 +903,7 @@ void SetupDisplay(){
 			    BlackPixel(qtdisplay,XDefaultScreen(qtdisplay)),
 			    WhitePixel(qtdisplay,XDefaultScreen(qtdisplay)));
 
-  PaintGC = XCreateGC(qtdisplay, Win, 0L, (XGCValues *) NULL);
+  PaintGC = XCreateGC(qtdisplay, Win, 0L, (XGCValues *) nullptr);
   XSetForeground(qtdisplay, PaintGC, BlackPixel(qtdisplay, XDefaultScreen(qtdisplay) ));
   XSetBackground(qtdisplay, PaintGC, WhitePixel(qtdisplay, XDefaultScreen(qtdisplay) ));
   XSetFunction(qtdisplay, PaintGC, GXcopy);
@@ -1052,7 +1052,7 @@ void TopLevel::handle_X_event(XEvent Event)
       case XK_q:
 	if (viewpage) {
 	  thispage = viewpage;
-	  viewpage = NULL;
+	  viewpage = nullptr;
 	  newPage();
 	  resizeView();
 	  putImage();
@@ -1152,7 +1152,7 @@ void TopLevel::rotatePage()
 
   XDefineCursor(qtdisplay, Win, ReadyCursor);
 
-  if(newrotimage == NULL){ // out of memory
+  if(!newrotimage){ // out of memory
     return;
   }
 
@@ -1181,7 +1181,7 @@ void TopLevel::flipPage()
 
   XDefineCursor(qtdisplay, Win, ReadyCursor);
 
-  if(newflipimage == NULL){ // out of memory
+  if(!newflipimage){ // out of memory
     return;
   }
 
@@ -1207,7 +1207,7 @@ void TopLevel::mirrorPage()
 
   XDefineCursor(qtdisplay, Win, ReadyCursor);
 
-  if(newmirror == NULL){ // out of memory
+  if(!newmirror){ // out of memory
     return;
   }
   thispage->extra = Images[0] = newmirror;
@@ -1251,7 +1251,7 @@ void TopLevel::lastPage()
 
   if ( thispage->next )
   {
-    while(thispage->next != NULL)
+    while(thispage->next)
       thispage = thispage->next;
 
     newPage();
@@ -1269,7 +1269,7 @@ void TopLevel::firstPage()
 
   if ( thispage->prev )
   {
-    while(thispage->prev != NULL)
+    while(thispage->prev)
       thispage = thispage->prev;
 
     newPage();
@@ -1331,7 +1331,7 @@ void TopLevel::newPage(){
     return;
   }
 
-  if (Pimage(thispage) == NULL){
+  if (!Pimage(thispage)){
 
     while((k != 0) && (k != 3) && (k !=1))
       k = GetImage(thispage);
@@ -1399,11 +1399,11 @@ void TopLevel::FreeFax()
   for (pn = firstpage; pn; pn = pn->next){
     if(Pimage(pn)){
        FreeImage(Pimage(pn));
-       pn->extra = NULL;
+       pn->extra = nullptr;
     }
   }
 
-  Image = NULL;
+  Image = nullptr;
 
   for (pn = firstpage; pn; pn = pn->next){
     if(pn->pathname){
@@ -1423,7 +1423,7 @@ void TopLevel::FreeFax()
   if(lastpage)
     free(lastpage);
 
-  firstpage = lastpage = viewpage = thispage = auxpage = NULL;
+  firstpage = lastpage = viewpage = thispage = auxpage = nullptr;
 
   uiUpdate();
 }
diff --git a/kfaxview/libkfaximage/kfaximage.cpp b/kfaxview/libkfaximage/kfaximage.cpp
index 6da8486c..f5153cfc 100644
--- a/kfaxview/libkfaximage/kfaximage.cpp
+++ b/kfaxview/libkfaximage/kfaximage.cpp
@@ -114,7 +114,7 @@ pagenode *KFaxImage::AppendImageNode(int type)
     if (pn) {
 	pn->type = type;
         pn->expander = g31expand;
-	pn->strips = NULL;
+	pn->strips = nullptr;
 	pn->size = TQSize(1728,2339);
 	pn->vres = -1;
 	pn->dpi = KFAX_DPI_FINE;
@@ -138,7 +138,7 @@ bool KFaxImage::NewImage(pagenode *pn, int w, int h)
 void KFaxImage::FreeImage(pagenode *pn)
 {
     pn->image = TQImage();
-    pn->data = NULL;
+    pn->data = nullptr;
     pn->bytes_per_line = 0;
 }
 
@@ -181,7 +181,7 @@ KFaxImage::notetiff()
     unsigned char header[8];
     TQImage::Endian endian;
     t32bits IFDoff;
-    pagenode *pn = NULL;
+    pagenode *pn = nullptr;
     TQString str;
 
     TQFile file(filename());
@@ -210,7 +210,7 @@ KFaxImage::notetiff()
     }
     do {			/* for each page */
 	unsigned char buf[8];
-	unsigned char *dir = NULL , *dp = NULL;
+	unsigned char *dir = nullptr , *dp = nullptr;
 	int ndirent;
 	pixnum iwidth = 1728;
 	pixnum iheight = 2339;
@@ -219,7 +219,7 @@ KFaxImage::notetiff()
 	int t4opt = 0, comp = 0;
 	int orient = TURN_NONE;
 	int yres = 196; /* 98.0 */
-	struct strip *strips = NULL;
+	struct strip *strips = nullptr;
 	unsigned int rowsperstrip = 0;
 	t32bits nstrips = 1;
 
@@ -366,7 +366,7 @@ KFaxImage::notetiff()
 	}
 	IFDoff = get4(dp, endian);
 	free(dir);
-	dir = NULL;
+	dir = nullptr;
 	if (comp == 5) {
           // compression type 5 is LZW compression // XXX
 	  kfaxerror(i18n("Due to patent reasons LZW (Lempel-Ziv & Welch) "
@@ -457,10 +457,10 @@ KFaxImage::getstrip(pagenode *pn, int strip)
     TQFile file(filename());
     if (!file.open(IO_ReadOnly)) {
 	badfile(pn);
-	return NULL;
+	return nullptr;
     }
 
-    if (pn->strips == NULL) {
+    if (!pn->strips) {
 	offset = 0;
 	pn->length = file.size();
     }
@@ -470,7 +470,7 @@ KFaxImage::getstrip(pagenode *pn, int strip)
     }
     else {
       kfaxerror( i18n("Trying to expand too many strips.") );
-      return NULL;
+      return nullptr;
     }
 
     /* round size to full boundary plus t32bits */
@@ -487,12 +487,12 @@ KFaxImage::getstrip(pagenode *pn, int strip)
 	(size_t) file.readBlock((char *)Data, pn->length) != pn->length) { 
 	badfile(pn);
 	free(Data);
-	return NULL;
+	return nullptr;
     }
     file.close();
 
     pn->data = (t16bits *) Data;
-    if (pn->strips == NULL && memcmp(Data, FAXMAGIC, sizeof(FAXMAGIC)-1) == 0) {
+    if (!pn->strips && memcmp(Data, FAXMAGIC, sizeof(FAXMAGIC)-1) == 0) {
 	/* handle ghostscript / PC Research fax file */
       if (Data[24] != 1 || Data[25] != 0){
 	kfaxerror( i18n("Only the first page of the PC Research multipage file will be shown.") );
@@ -511,9 +511,9 @@ KFaxImage::getstrip(pagenode *pn, int strip)
       kfaxerror( i18n("No fax found in file.") );
       badfile(pn);
       free(Data);
-      return NULL;
+      return nullptr;
     }
-    if (pn->strips == NULL)
+    if (!pn->strips)
 	pn->rowsperstrip = pn->size.height();
     return Data;
 }
-- 
cgit v1.2.3

