[MacPorts] #70248: cdf @3.8.1: Checksum mismatch (was: cdf fails to install with mismatched checksum)

MacPorts noreply at macports.org
Wed Jun 19 00:39:39 UTC 2024


#70248: cdf @3.8.1: Checksum mismatch
-----------------------+------------------------
  Reporter:  bernstei  |      Owner:  ryandesign
      Type:  defect    |     Status:  accepted
  Priority:  Normal    |  Milestone:
 Component:  ports     |    Version:  2.9.3
Resolution:            |   Keywords:
      Port:  cdf       |
-----------------------+------------------------
Changes (by ryandesign):

 * status:  new => accepted
 * owner:  (none) => ryandesign
 * port:   => cdf
 * keywords:  cdf checksum =>


Comment:

 I agree, the [PortfileRecipes#stealth-updates distfile has changed] since
 I last updated this port:

 {{{
 % sudo port fetch --no-mirrors cdf
 --->  Fetching distfiles for cdf
 --->  Attempting to fetch cdf38_1-dist-all.tar.gz from
 https://spdf.gsfc.nasa.gov/pub/software/cdf/dist/cdf38_1/unix/
 % sudo port checksum cdf
 --->  Verifying checksums for cdf
 Error: Checksum (rmd160) mismatch for cdf38_1-dist-all.tar.gz
 Error: Checksum (sha256) mismatch for cdf38_1-dist-all.tar.gz
 Error: Checksum (size) mismatch for cdf38_1-dist-all.tar.gz
 Error: Failed to checksum cdf: Unable to verify file checksums
 }}}

 There is a new 3.9.0 version available to which I have been meaning to
 update the port, but I would like to understand why the 3.8.1 distfile
 changed. There is a rather extensive difference between the old 3.8.1
 (March 15, 2022) and the new 3.8.1 (April 25, 2022):

 {{{#!diff
 diff -ru old/cdf38_1-dist/Makefile new/cdf38_1-dist/Makefile
 --- old/cdf38_1-dist/Makefile   2022-03-09 10:23:07.000000000 -0600
 +++ new/cdf38_1-dist/Makefile   2022-03-31 09:26:21.000000000 -0500
 @@ -1076,7 +1076,6 @@
          fi
         @if [ -f $(JNIsrcDIR)/libcdfNativeLibrary.jnilib ] ; then \
            $(MAKE) $(EXTRAMAKE) MAKE=$(MAKE) "INSTALLDIR=$(INSTALLDIR)"
 install.lib.jnilib ; \
 -          $(MAKE) $(EXTRAMAKE) MAKE=$(MAKE)
 "INSTALLDIR=$(MYHOME)/Library/Java/Extensions" install.lib.jnilib2 ; \
          else \
            $(NULL) ; \
          fi
 @@ -1246,10 +1245,16 @@
         @if [ -f $(JNIsrcDIR)/libcdfNativeLibrary.jnilib ] ; then \
           echo cp $(JNIsrcDIR)/libcdfNativeLibrary.jnilib
 $(INSTALLDIR)/lib/libcdfNativeLibrary.$(VERSION).jnilib ; \
           cp $(JNIsrcDIR)/libcdfNativeLibrary.jnilib
 $(INSTALLDIR)/lib/libcdfNativeLibrary.$(VERSION).jnilib ; \
 +         mkdir -p $(MYHOME)/lib ; \
 +         echo cp $(JNIsrcDIR)/libcdfNativeLibrary.jnilib
 $(MYHOME)/lib/libcdfNativeLibrary.$(VERSION).jnilib ; \
 +         cp $(JNIsrcDIR)/libcdfNativeLibrary.jnilib
 $(MYHOME)/lib/libcdfNativeLibrary.$(VERSION).jnilib ; \
 +         mkdir -p $(MYHOME)/Library/Java/Extensions ; \
           echo cp $(JNIsrcDIR)/libcdfNativeLibrary.jnilib
 $(MYHOME)/Library/Java/Extensions/libcdfNativeLibrary.$(VERSION).jnilib ;
 \
           cp $(JNIsrcDIR)/libcdfNativeLibrary.jnilib
 $(MYHOME)/Library/Java/Extensions/libcdfNativeLibrary.$(VERSION).jnilib ;
 \
           rm -f $(INSTALLDIR)/lib/libcdfNativeLibrary.jnilib ; \
           cd $(INSTALLDIR)/lib && ln -s
 libcdfNativeLibrary.$(VERSION).jnilib libcdfNativeLibrary.jnilib ; \
 +         rm -f $(MYHOME)/lib/libcdfNativeLibrary.jnilib ; \
 +         cd $(MYHOME)/lib && ln -s libcdfNativeLibrary.$(VERSION).jnilib
 libcdfNativeLibrary.jnilib ; \
           rm -f
 $(MYHOME)/Library/Java/Extensions/libcdfNativeLibrary.jnilib ; \
           cd $(MYHOME)/Library/Java/Extensions && ln -s
 libcdfNativeLibrary.$(VERSION).jnilib libcdfNativeLibrary.jnilib ; \
         fi
 diff -ru old/cdf38_1-dist/Release.notes new/cdf38_1-dist/Release.notes
 --- old/cdf38_1-dist/Release.notes      2022-02-15 07:15:03.000000000
 -0600
 +++ new/cdf38_1-dist/Release.notes      2022-03-31 09:53:10.000000000
 -0500
 @@ -137,14 +137,14 @@

  The CDF documentation set consists of the following:

 -        cdf363ug.pdf   (CDF User's Guide)
 -        cdf363crm.pdf  (CDF C Reference Manual)
 -        cdf363frm.pdf  (CDF Fortran Reference Manual)
 -        cdf363prm.pdf  (CDF Perl Reference Manual)
 -        cdf363jrm.pdf  (CDF Java Reference Manual)
 -        cdf363csrm.pdf (CDF C# Reference Manual)
 -        cdf363vbrm.pdf (CDF Visual Basic Reference Manual)
 -        cdf36ifd.pdf   (CDF Internal Format Description)
 +        cdf381ug.pdf   (CDF User's Guide)
 +        cdf381crm.pdf  (CDF C Reference Manual)
 +        cdf381frm.pdf  (CDF Fortran Reference Manual)
 +        cdf381prm.pdf  (CDF Perl Reference Manual)
 +        cdf381jrm.pdf  (CDF Java Reference Manual)
 +        cdf381csrm.pdf (CDF C# Reference Manual)
 +        cdf381vbrm.pdf (CDF Visual Basic Reference Manual)
 +        cdf38ifd.pdf   (CDF Internal Format Description)

  These documents are available from the CDF home page
 (http://cdf.gsfc.nasa.gov).

 diff -ru old/cdf38_1-dist/cdfjava/cdfjson/CDF2Json.java
 new/cdf38_1-dist/cdfjava/cdfjson/CDF2Json.java
 --- old/cdf38_1-dist/cdfjava/cdfjson/CDF2Json.java      2022-02-25
 10:47:33.000000000 -0600
 +++ new/cdf38_1-dist/cdfjava/cdfjson/CDF2Json.java      2022-04-20
 09:51:26.000000000 -0500
 @@ -189,7 +189,7 @@
      private static String item8 = "GlobalAttributes";
      private static String item9 = "VariableAttributes";
      private static String separator =
 System.getProperty("file.separator");
 -
 +private static long numDimsN;
      public static void main(String[] args) throws Exception {

          try {
 @@ -738,7 +738,7 @@
              dimSizes         = v.getDimSizes();
              dimVariances     = v.getDimVariances();

 -            long numDimsN;
 +//            long numDimsN;
              long[] dimSizesN = new long[(int)CDF_MAX_DIMS];
              numDimsN = 0;
              for (i = 0; i < numDims; i++) {
 @@ -748,7 +748,6 @@
                  ++numDimsN;
                }
              }
 -
              JsonObjectBuilder nd = Json.createObjectBuilder().
                                          add("NumDims",numDimsN);
              infos.add (nd.build());
 @@ -979,7 +978,7 @@
              long[]  dimSizes = {1L}, dimVariances;
              long[]  dimIndices   = {0L};
              long[]  dimIntervals = {1L};
 -            long numDimsN = 0;
 +//            long numDimsN = 0;
              long[] dimSizesN = null;
              maxRec = v.getMaxWrittenRecord();

 @@ -998,6 +997,7 @@
              dataType     = v.getDataType();
              dimVariances = v.getDimVariances();
              numValuesToRead = 1;
 +/*
              if (numDims > 0) {
                  dimIntervals = new long[dimSizes.length];
                  dimIndices   = new long[dimSizes.length];
 @@ -1015,6 +1015,24 @@
                       numValuesToRead *= dimSizes[i];
                  }
              }
 +*/
 +            if (numDimsN > 0) {
 +                dimIntervals = new long[(int)numDimsN];
 +                dimIndices   = new long[(int)numDimsN];
 +                dimSizesN    = new long[(int)numDimsN];
 +                int j = 0;
 +//                numDimsN = 0;
 +                for (int i=0; i < numDimsN; i++) {
 +                     if (dimVariances[i] == VARY) {
 +//                       ++numDimsN;
 +                       dimSizesN[j] = dimSizes[i];
 +                       ++j;
 +                     }
 +                     dimIntervals[i] = 1;
 +                     dimIndices[i]   = 0;
 +                     numValuesToRead *= dimSizes[i];
 +                }
 +            }

              JsonArrayBuilder records = Json.createArrayBuilder();

 @@ -1040,15 +1058,16 @@
                       numRecordsToRead = maxRec - i + 1;
                   else
                       numRecordsToRead = incrementCounter;
 -                 if (numDimsN > 0)
 +                 if (numDimsN > 0) {
                       cdfdata = v.getHyperDataObject((long) i,
                                                      numRecordsToRead, 1L,
                                                      dimIndices,
                                                      dimSizes,
                                                      dimIntervals);
 -                 else
 +                 } else {
                       cdfdata = v.getRecordsObject((long) i,
                                                     numRecordsToRead);
 +                 }
                   // Get the status of the last CDF call
                   long status = cdf.getStatus();
                   Object dataArray = cdfdata.getData();
 @@ -1068,7 +1087,7 @@
                        } else
                            datum = dataArray;

 -                      if (numDims != numDimsN) {
 +                      if (numDimsN > 0 && numDims != numDimsN) {
                          // Filled data for non-varying dimension(s)
                          long iz;
                          iz = numDims;
 @@ -1077,6 +1096,7 @@
                            --iz;
                          }
                        }
 +
                        if (numDimsN < 2) {
                          boolean single = false;
                          if (!recVary || maxRec == 0) single = true;
 @@ -1085,7 +1105,7 @@
                                                      datum, dataType,
 numDimsN,
                                                      -1, (withz?"Z":""),
 formatT,
                                                      fillVal, single);
 -                      } else {
 +                      } else {
                           JsonArrayBuilder oData = printMultipleData
 (datum,
                                                      dataType,
 (int)numDimsN,
                                                      dimSizes,
 diff -ru old/cdf38_1-dist/cdfjava/cdfjson/CDFJsonReader.java
 new/cdf38_1-dist/cdfjava/cdfjson/CDFJsonReader.java
 --- old/cdf38_1-dist/cdfjava/cdfjson/CDFJsonReader.java 2022-02-25
 10:10:32.000000000 -0600
 +++ new/cdf38_1-dist/cdfjava/cdfjson/CDFJsonReader.java 2022-04-20
 09:41:31.000000000 -0500
 @@ -89,15 +89,19 @@
         boolean toVar = false;
         // Retrieve data from "CDFVariables" JsonArray
         JsonArray cdfVariables = jsonObject1.getJsonArray(item3);
 +       String format = null;
 +       long dataType = 0;
         if (cdfVariables != null) {
           System.out.println("  "+item3+":");
 +         format = null;
 +         dataType = 0;
           for (JsonValue varInfo : cdfVariables) {
             for (String key: ((JsonObject)varInfo).keySet()) {
               JsonArray var = ((JsonObject)varInfo).getJsonArray(key);
               JsonObject varItem = var.getJsonObject(0);
               if (varCount > 0) toShow = checkVar (varItem);
               if (!toShow) continue;
 -             System.out.println("    "+key+":"); // Variable
 +             System.out.println("    "+key+":"); // Variable name
               for (int ii = 0; ii < var.size(); ++ii) { // VarDescription
 |
                                                         // VarAttributes |
                                                         // VarData
 @@ -111,7 +115,7 @@
                     // VarDescription:
                     System.out.println("      "+varKey+":"+value);
                   } else if (value instanceof JsonArray) {
 -                   // VarDescription:
 +                   // VarDescription: | VarAttributes: | VarData:
                     System.out.println("      "+varKey+":");
                     int valueN = ((JsonArray)value).size();
                     boolean breakout = false;
 @@ -120,12 +124,21 @@
                       if (data instanceof JsonObject) {
                         for (String keyx: ((JsonObject)data).keySet()) {
                           Object des = ((JsonObject)data).get(keyx);
 +                         // DataType: | VALIDMIN:
                           System.out.println("        "+keyx+":"+des);
                           if (!toVarDesc &&
 keyx.equalsIgnoreCase("varname"))
                             breakout = true;
                           if (keyx.equals("RecVariance")) {
                             if (des.toString().equals("\"NOVARY\""))
 toVar= true;
                           }
 +                         if (keyx.equalsIgnoreCase("format")) {
 +                           format = toCformat(des.toString().
 +                                                  replaceAll("^\"|\"$",
 ""));
 +                         }
 +                         if (keyx.equalsIgnoreCase("datatype")) {
 +                           dataType = CDFUtils.getDataTypeValue(
 +
 des.toString().replaceAll("^\"|\"$", ""));
 +                         }
                         }
                       } else if (data instanceof JsonArray) {
                         System.out.print("        [");
 @@ -138,7 +151,15 @@
                       } else if (data instanceof JsonNumber ||
                                  data instanceof JsonString) {
                         if (jj == 0) System.out.print("      [");
 -                       System.out.print(data+(jj<(valueN-1)?", ":""));
 +                       if (data instanceof JsonString || format == null
 ||
 +                           (dataType != CDF_REAL4 && dataType !=
 CDF_REAL8 &&
 +                            dataType != CDF_FLOAT && dataType !=
 CDF_DOUBLE))
 +                         System.out.print(data+(jj<(valueN-1)?", ":""));
 +                       else
 +                         System.out.print(
 +                            String.format(format,((JsonNumber)data).
 +
 doubleValue())+
 +                            (jj<(valueN-1)?", ":""));
                         if (jj == (valueN - 1)) System.out.println("]");
                       } else {
                         System.out.println("        "+data);
 @@ -313,4 +334,55 @@
         System.out.println (" ");
      }

 +    private static String toCformat (String oFormat) {
 +       if (oFormat.charAt(0) == '%') return oFormat;
 +
 /***********************************************************************
 +        *      FORTRAN format form
 +        * Change `oformat' to point to first non-blank, non-digit,
 non-`('
 +        * character.  This will skip over a Fortran repeat count (eg. the
 `20'
 +        * in `20F8.4' or `20(F8.4)').
 +
 ***********************************************************************/
 +       oFormat = oFormat.trim();
 +       if (oFormat == null) return null;
 +       int len = oFormat.length();
 +       String formatY = null;
 +       for (int i = 0; i < len; ++i) {
 +         char a = oFormat.charAt(i);
 +         if (Character.isDigit(a) || a == '(') continue;
 +         formatY = oFormat.substring(i);
 +         if (formatY.endsWith(")"))
 +           formatY = formatY.substring(0, formatY.length()-1);
 +         break;
 +       }
 +       if (formatY == null) return null;
 +       String cformat;
 +
 /***********************************************************************
 +        * Encode C format specification.
 +
 ***********************************************************************/
 +       switch (formatY.charAt(0)) {
 +
 /*********************************************************************
 +          * Integer/decimal.
 +
 *********************************************************************/
 +         case 'I':
 +         case 'i':
 +           cformat = formatY.substring(1);
 +           return "%"+cformat+"d";
 +
 /*********************************************************************
 +          * Floating-point/non-scientific notation (which is called...
 +
 *********************************************************************/
 +         case 'F':
 +         case 'f':
 +           cformat = formatY.substring(1);
 +           return "%"+cformat+"f";
 +
 /*********************************************************************
 +          * Floating-point/scientific notation.
 +
 *********************************************************************/
 +         case 'E':
 +         case 'e':
 +           cformat = formatY.substring(1);
 +           return "%"+cformat+"e";
 +       }
 +       return null;
 +    }
 +
  }
 Only in new/cdf38_1-dist/cdfjava/cdfjson: po.txt
 Only in new/cdf38_1-dist/cdfjava/cdfjson: wi.txt
 Binary files old/cdf38_1-dist/cdfjava/classes/cdfjava.jar and
 new/cdf38_1-dist/cdfjava/classes/cdfjava.jar differ
 Binary files old/cdf38_1-dist/cdfjava/classes/cdfjson.jar and
 new/cdf38_1-dist/cdfjava/classes/cdfjson.jar differ
 Only in old/cdf38_1-dist/cdfjava/examples: TUTF8a.cdf
 Only in old/cdf38_1-dist/cdfjava/examples: tUTF8.cdf
 diff -ru old/cdf38_1-dist/src/include/cdf.h
 new/cdf38_1-dist/src/include/cdf.h
 --- old/cdf38_1-dist/src/include/cdf.h  2022-02-26 07:00:32.000000000
 -0600
 +++ new/cdf38_1-dist/src/include/cdf.h  2022-03-22 07:17:03.000000000
 -0500
 @@ -1779,7 +1779,7 @@
  VISIBLE_PREFIX CDFstatus CDFgetAttrStrEntry PROTOARGs((
    CDFid id, int grzEntry, long attrNum, long entryNum, char **string
  ));
 -//#if defined(WIN32)
 +/* #if defined(WIN32) */
  VISIBLE_PREFIX CDFstatus CDFputAttrWStrEntry PROTOARGs((
    CDFid id, int grzEntry, long attrNum, long entryNum, wchar_t *wstring,
    char *locale
 @@ -1788,7 +1788,7 @@
    CDFid id, int grzEntry, long attrNum, long entryNum, wchar_t **wstring,
    char *locale
  ));
 -//#endif
 +/* #endif */
  VISIBLE_PREFIX CDFstatus CDFgetAttrEntryNumStrings PROTOARGs((
    CDFid id, int rzEntry, long attrNum, long entryNum,
    long *numStrings
 diff -ru old/cdf38_1-dist/src/lib/cdftt2000.c
 new/cdf38_1-dist/src/lib/cdftt2000.c
 --- old/cdf38_1-dist/src/lib/cdftt2000.c        2021-09-10
 12:16:19.000000000 -0500
 +++ new/cdf38_1-dist/src/lib/cdftt2000.c        2022-04-25
 07:03:28.000000000 -0500
 @@ -38,9 +38,18 @@
  #define HOURinNanoSecs          3600000000000LL
  #define MINUTEinNanoSecs        60000000000LL
  #define T12hinNanoSecs          43200000000000LL
 -/* Julian days for 1707-09-22 and 2292-04-11, the valid TT2000 range. */
 +/* Julian days for 1707-09-22T12:12:10.961224192 and
 + * 2292-04-11T11:46:07.670775807, the valid TT2000 range. */
 +/* 1707-09-22T12:12:10.961224192 reserved as FILLVAL */
 +/*                               (encoded as
 9999-12-31T23:59:59.999999999) */
 +/* 1707-09-22T12:12:10.961224193 reserved as PADVAL */
 +/*                               (encoded as
 0000-01-01T00:00:00.000000000) */
 +/* 1707-09-22T12:12:10.961224195 reserved as ILLEGAL_VAL */
 +/*                               (encoded as
 9999-12-31T23:59:59.999999999) */
  #define JDY17070922             2344793
 +#define JDY17070922subdayns     43930961224192LL
  #define JDY22920411             2558297
 +#define JDY22920411subdayns     42367670775807LL

  /* Number of Delta(dAT) expressions before leap seconds were introduced
 */
  #define NERA1 14
 @@ -959,7 +968,7 @@
    long lyl, lml, ldl, lhl, lnl, lsl, lll, lul, lal;
    long xy, xm, xd;
    int  lyear;
 -
 +  double jday12h = 0.0;
  #if defined(STDARG)
    va_start (ap, dd);
  #else
 @@ -1105,8 +1114,8 @@
      ls += as;
      ll += al;
      lu += au;
 -    tmp = JulianDay12h ((long) ly, (long) lm, (long) ld);
 -    DatefromJulianDay (tmp, &lyl, &lml, &ldl);
 +    jday12h = JulianDay12h ((long) ly, (long) lm, (long) ld);
 +    DatefromJulianDay (jday12h, &lyl, &lml, &ldl);
    }
    if (lu >= 1000.0) {
      double ad, ah, am, as, al;
 @@ -1125,8 +1134,8 @@
      ln += am;
      ls += as;
      ll += al;
 -    tmp = JulianDay12h ((long) ly, (long) lm, (long) ld);
 -    DatefromJulianDay (tmp, &lyl, &lml, &ldl);
 +    jday12h = JulianDay12h ((long) ly, (long) lm, (long) ld);
 +    DatefromJulianDay (jday12h, &lyl, &lml, &ldl);
    }
    if (ll >= 1000.0) {
      double ad, ah, am, as;
 @@ -1142,8 +1151,8 @@
      lh += ah;
      ln += am;
      ls += as;
 -    tmp = JulianDay12h ((long) ly, (long) lm, (long) ld);
 -    DatefromJulianDay (tmp, &lyl, &lml, &ldl);
 +    jday12h = JulianDay12h ((long) ly, (long) lm, (long) ld);
 +    DatefromJulianDay (jday12h, &lyl, &lml, &ldl);
    }
    if (ls >= 60.0) {
      tmp = JulianDay12h ((long) ly, (long) lm, (long) ld);
 @@ -1161,8 +1170,8 @@
        ld += ad;
        lh += ah;
        ln += am;
 -      tmp = JulianDay12h ((long) ly, (long) lm, (long) ld);
 -      DatefromJulianDay (tmp, &lyl, &lml, &ldl);
 +      jday12h = JulianDay12h ((long) ly, (long) lm, (long) ld);
 +      DatefromJulianDay (jday12h, &lyl, &lml, &ldl);
      }
    }
    if (ln >= 60.0) {
 @@ -1173,16 +1182,16 @@
      ln = ln - ah * 60;
      ld += ad;
      lh += ah;
 -    tmp = JulianDay12h ((long) ly, (long) lm, (long) ld);
 -    DatefromJulianDay (tmp, &lyl, &lml, &ldl);
 +    jday12h = JulianDay12h ((long) ly, (long) lm, (long) ld);
 +    DatefromJulianDay (jday12h, &lyl, &lml, &ldl);
    }
    if (lh >= 24.0) {
      double ad;
      ad = floor(lh / 24.0);
      lh = lh - ad * 24.0;
      ld += ad;
 -    tmp = JulianDay12h ((long) ly, (long) lm, (long) ld);
 -    DatefromJulianDay (tmp, &lyl, &lml, &ldl);
 +    jday12h = JulianDay12h ((long) ly, (long) lm, (long) ld);
 +    DatefromJulianDay (jday12h, &lyl, &lml, &ldl);
    }
    if (lyl == -999 && lml == -999) {
      lyl = (long) ly;
 @@ -1204,6 +1213,16 @@
      return DEFAULT_TT2000_PADVALUE;
    if (!YearWithin(lyl) && !ValidateYMD(lyl,lml,ldl))
      return ILLEGAL_TT2000_VALUE;
 +  if (jday12h == 0.0)  jday12h = JulianDay12h (lyl, lml, ldl);
 +  if (jday12h == JDY22920411) {
 +    long long subday = (long long) (3600*lhl+60*lnl+lsl)*1000000000LL+
 +                       lll*1000000LL+lul*1000LL+lal;
 +    if (subday > JDY22920411subdayns) return ILLEGAL_TT2000_VALUE;
 +  } else if (jday12h == JDY17070922) {
 +    long long subday = (long long) (3600*lhl+60*lnl+lsl)*1000000000LL+
 +                       lll*1000000LL+lul*1000LL+lal;
 +    if (subday < JDY17070922subdayns) return ILLEGAL_TT2000_VALUE;
 +  }
    lyear = (lyl & 3) == 0 && ((lyl % 25) != 0 || (lyl & 15) == 0);
    if ((!lyear && ldl > 365) || (lyear && ldl > 366))
      return ILLEGAL_TT2000_VALUE;
 diff -ru old/cdf38_1-dist/src/tools/cdf2skt.c
 new/cdf38_1-dist/src/tools/cdf2skt.c
 --- old/cdf38_1-dist/src/tools/cdf2skt.c        2022-02-23
 13:42:35.000000000 -0600
 +++ new/cdf38_1-dist/src/tools/cdf2skt.c        2022-03-25
 11:02:51.000000000 -0500
 @@ -917,6 +917,7 @@
    long sarray[CDF_MAX_PARMS];
    char *format;
    int  howto;
 +  int  varNameLen;
    format = NULL;
    sarray[0] = 0;
    status = CDFlib (SELECT_, VAR(zVar), varN,
 @@ -1048,15 +1049,43 @@

 /***************************************************************************
    * Write variable definition line.
 +  * Variable name might break into multiple lines if its length is more
 than
 +  * 74 characters. In this case, an extra "-" is appended to the end for
 +  * an indication of continuation.
 ***************************************************************************/

    WriteOut (SKTfp, "\n");

    delim = PickDelimiter (varName, strlen(varName));
    WriteOut (SKTfp, "\n");
 -  snprintf (tempS, (size_t) sizeof(tempS), "  %c%s%c", delim, varName,
 delim);
 -  ccc = WriteOut (SKTfp, tempS);
 -
 +  varNameLen = (int) strlen(varName);
 +  if (varNameLen < 75) {
 +    snprintf (tempS, (size_t) sizeof(tempS), "  %c%s%c", delim, varName,
 delim);
 +    ccc = WriteOut (SKTfp, tempS);
 +  } else {
 +    int len, ix;
 +    char namePart[73];
 +    len = varNameLen;
 +    ix = 0;
 +    while (len >= 72) {
 +      strncpy(namePart, varName+ix, 72);
 +      namePart[72] = (char ) '\0';
 +      snprintf (tempS, (size_t) sizeof(tempS), "  %c%s%c %c", delim,
 namePart,
 +                delim,(len==72?' ':'-'));
 +      ccc = WriteOut (SKTfp, tempS);
 +      WriteOut (SKTfp, "\n");
 +      ix += 72;
 +      len -= 72;
 +    }
 +    if (len > 0) {
 +      strcpyX(namePart, varName+ix, 72);
 +      snprintf (tempS, (size_t) sizeof(tempS), "  %c%s%c", delim,
 namePart,
 +                delim);
 +      ccc = WriteOut (SKTfp, tempS);
 +      WriteOut (SKTfp, "\n");
 +      ccc = 0;
 +    }
 +  }
    if (varDataType != CDF_TIME_TT2000) ddd = 0;
    else ddd = 4;

 diff -ru old/cdf38_1-dist/src/tools/cdfedit2.c
 new/cdf38_1-dist/src/tools/cdfedit2.c
 --- old/cdf38_1-dist/src/tools/cdfedit2.c       2022-03-15
 15:32:26.000000000 -0500
 +++ new/cdf38_1-dist/src/tools/cdfedit2.c       2022-04-14
 10:42:32.000000000 -0500
 @@ -1012,9 +1012,30 @@
                     long nElemsEntered; void *newBinary;
                      int style;
                      if (TT2000dataType(dataType)) {
 -                      if (!ziso8601) style = TT2000_3_STYLE;
 -                      else style = TT2000_4_STYLE;
 -                    } else {
 +                      if (!ziso8601) {
 +                       style = TT2000_3_STYLE;
 +                       *((char *)(PW.value)+TT2000_3_STRING_LEN) = (char)
 '\0';
 +                     } else {
 +                       style = TT2000_4_STYLE;
 +                       *((char *)(PW.value)+TT2000_4_STRING_LEN) = (char)
 '\0';
 +                     }
 +                    } else if (EPOCHdataType(dataType)) {
 +                      if (!ziso8601) {
 +                       style = EPOCH4_STYLE;
 +                       *((char *)(PW.value)+EPOCH4_STRING_LEN) = (char)
 '\0';
 +                     } else {
 +                       style = EPOCH3_STYLE;
 +                       *((char *)(PW.value)+EPOCH3_STRING_LEN) = (char)
 '\0';
 +                     }
 +                    } else if (EPOCH16dataType(dataType)) {
 +                      if (!ziso8601) {
 +                       style = EPOCH4_STYLE;
 +                       *((char *)(PW.value)+EPOCH16_4_STRING_LEN) =
 (char) '\0';
 +                     } else {
 +                       style = EPOCH3_STYLE;
 +                       *((char *)(PW.value)+EPOCH16_3_STRING_LEN) =
 (char) '\0';
 +                     }
 +                   } else {
                        if (!ziso8601) style = DEFAULTstyleEDIT;
                        else style = EPOCH3_STYLE;
                      }
 Only in old/cdf38_1-dist/src/tools: cfxp3.c
 diff -ru old/cdf38_1-dist/src/tools/skt2cdf.c
 new/cdf38_1-dist/src/tools/skt2cdf.c
 --- old/cdf38_1-dist/src/tools/skt2cdf.c        2021-09-16
 10:08:01.000000000 -0500
 +++ new/cdf38_1-dist/src/tools/skt2cdf.c        2022-03-25
 09:51:43.000000000 -0500
 @@ -122,6 +122,7 @@
  #ifdef WIN32
    static unsigned int oldCodePage = 0;
  #endif
 +static Logical longVar;

 /******************************************************************************
  * Main.
 @@ -520,8 +521,12 @@
         if (token[0] != NUL)
           if (!ItemStream(token)) return FALSE;
        }
 -      else
 -       CATchr (&token, chr, &tokenZ, BASE_TOKEN_SIZE);
 +      else {
 +        /* For a long variable name that spans more than one line, skip
 that
 +           '-' character in its first line... */
 +        if (!longVar || chr != (int) '-')
 +         CATchr (&token, chr, &tokenZ, BASE_TOKEN_SIZE);
 +      }
        break;
 /**************************************************************************
      *
 @@ -631,7 +636,7 @@
                 break;
             }
        else
 -       if (startBraceFound)
 +       if (startBraceFound) {
           if (inString) {
             if (lineN != stringLineN) {
               ParseError ("String/substring split across lines.");
 @@ -639,6 +644,7 @@
             }
             CATchr (&eValue, chr, &eValueZ, BASE_EVALUE_SIZE);
           }
 +       }
        break;
 /**************************************************************************
      *
 @@ -788,6 +794,7 @@
    int dN, dNt;         /* Dimension number. */
    void *padValue;
    size_t nBytes;
 +
 /****************************************************************************
    * Based on what should be next...
 ****************************************************************************/
 @@ -1429,7 +1436,8 @@
        long vAttrNum;
        strcpyX (vAttrName, item, CDF_ATTR_NAME_LEN256);
        if (!ISTPname (vAttrName) && warning)
 -        WriteOutFP (stdout, "Warning: Attribute name: \"%s\" not ISTP
 compliant... not recommended\n",
 +        WriteOutFP (stdout, "Warning: Attribute name: \"%s\" not ISTP "
 +                            "compliant... not recommended\n",
                      vAttrName);
        status = CDFlib (CREATE_, ATTR_, vAttrName, VARIABLE_SCOPE,
 &vAttrNum,
                        NULL_);
 @@ -1476,10 +1484,48 @@
 /**************************************************************************
      *
 **************************************************************************/
 -    case VARNAMEfield:
 -      strcpyX (varName, item, CDF_VAR_NAME_LEN256);
 +    case VARNAMEfield: {
 +      char *ptrs, *ptre, *tmpx;
 +      ptre = strrchr (line, '"');
 +      if (ptre && !strncmp(ptre, "\" -", 3)) {
 +        strcpyX (varName, item, 0);
 +        if (fgets(line,MAX_SKTLINE_LEN,SKTfp) == NULL) {
 +          ParseError ("Unexpected end-of-file.");
 +          FreeGrowingStrings ();
 +          return done;
 +        }
 +        ptrs = strchr (line, '"');
 +        ptre = strrchr (ptrs+1, '"');
 +        while (ptre && !strncmp(ptre, "\" -", 3)) {
 +          tmpx = (char *) malloc(ptre-ptrs);
 +          strncpy (tmpx, ptrs+1, ptre-ptrs-1);
 +          *(tmpx+(ptre-ptrs-1)) = (char ) '\0';
 +          strcatX (varName, tmpx, CDF_VAR_NAME_LEN256);
 +          free (tmpx);
 +          tmpx = NULL;
 +          if (fgets(line,MAX_SKTLINE_LEN,SKTfp) == NULL) {
 +            ParseError ("Unexpected end-of-file.");
 +            FreeGrowingStrings ();
 +            return done;
 +          }
 +          ptre = strrchr (line, '"');
 +        }
 +        ptrs = strchr (line, '"');
 +        ptre = strrchr (ptrs+1, '"');
 +        tmpx = (char *) malloc(ptre-ptrs);
 +        strncpy (tmpx, ptrs+1, ptre-ptrs-1);
 +        *(tmpx+(ptre-ptrs-1)) = (char ) '\0';
 +        strcatX (varName, tmpx, CDF_VAR_NAME_LEN256);
 +        free (tmpx);
 +        tmpx = NULL;
 +        longVar = TRUE;
 +      } else {
 +        strcpyX (varName, item, CDF_VAR_NAME_LEN256);
 +        longVar = FALSE;
 +      }
        NextSearchItem (TOKEN, VARDATATYPEfield);
        break;
 +    }
 /**************************************************************************
      *
 **************************************************************************/
 @@ -1574,7 +1620,8 @@
           zVar = BOO(zSection,TRUE,(zMode > zMODEoff));
            if (!ISTPname (varName) && warning)
              WriteOutFP (stdout,
 -                "Warning: Variable name: \"%s\" non-ISTP compliant... not
 recommended\n",
 +                "Warning: Variable name: \"%s\" non-ISTP compliant... not
 "
 +                 "recommended\n",
                          varName);
           if (zVar)
             status = CDFlib (CREATE_, zVAR_, varName, vDataType,
 vNumElems,
 Only in old/cdf38_1-dist/src/tools: tcdfedit1.c
 Only in old/cdf38_1-dist/src/tools: toolbox3n.c
 Only in old/cdf38_1-dist/src/tools: zz1n.c
 }}}

-- 
Ticket URL: <https://trac.macports.org/ticket/70248#comment:1>
MacPorts <https://www.macports.org/>
Ports system for macOS


More information about the macports-tickets mailing list