summaryrefslogtreecommitdiff
path: root/pcl
Commit message (Collapse)AuthorAgeFilesLines
* Update postal address in file headersChris Liddell2023-04-04199-599/+603
|
* Remove C99 style inline declarationChris Liddell2023-03-011-2/+5
|
* Debugging fixupsHenry Stiles2023-02-283-5/+107
| | | | | A character array was accessed incorrectly and we now include a complete dump of downloaded fonts with the font debugging option '='.
* Tweak parameter testing to use an 'argis' macro.Robin Watts2023-02-281-47/+39
| | | | | | | | | | | | | | | | | | At various places in the code, we test for parameters from a param_list by using: if (!strncmp(param, "ParamValue", strlen("ParamValue")) This is bad, because as well as matching "ParamValue" and "ParamValue=", it will also match "ParamValueSomething". Also, at various places in the code, we don't call strlen (understandably, cos that's a runtime function call to retrieve a constant value), and just wire in the constant value. But in at least 1 location, we've got the constant value wrong. Accordingly, move to using an 'argis' macro that tests correctly and calculates the length at compile time.
* Avoid GPDL 'pass_param_to_languages' early termination.Robin Watts2023-02-281-1/+1
| | | | | | | Only stop passing params to languages on an error, not on a non-zero return code. This was causing arguments not to make it to SO for processing.
* Bug 706389: Fix versioning format consistencyChris Liddell2023-02-271-3/+1
| | | | | | | | | | | | | The main code issue with this bug was that the banner printed on startup is printed from Postscript, and Postscript's cvs operator doesn't allow for dictating the number of digits it outputs so the number 00 will always end up as the string "0", or 01 as "1". So our 10.01.0 version would be printed as "10.1.0". To address this, as a ".revisionstring" entry to systemdict, created during startup, the string is created in C, so we control the format. The remaining issues need to be address as part of the release process.
* Fix another memory leak of param lists in gpdl.Robin Watts2023-02-221-1/+2
| | | | This is seen when we exit an instance with an error.
* Bug 706360: Catch and act on error code during PCL5 initChris Liddell2023-02-101-3/+6
| | | | | Missing fonts is a fatal error, and we were ignoring the error from pcl_do_resets() due to "missing" fonts (i.e. non-romfs configs not supported).
* Fix windows builds of gpdl, broken by utf8 change.Robin Watts2022-11-221-1/+1
| | | | | I missed a rename of gp_wutf8.c to gp_utf8.c in one of the many makefiles.
* Move gp_wutf8 functions to be gp_utf8.Robin Watts2022-11-211-3/+3
| | | | | | Promote previously windows specific functions to be generically available (and give them names that reflect that).
* Allow @file syntax to include files in the ROM file systemKen Sharp2022-11-214-15/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This started as a customer request, where the customer wanted to store a file in the ROM file system with a bunch of command line parameters in it, and then use the @file syntax to run that file and setup the interpreter. In essence a 'canned' setup stored in the ROM file system. That didn't work, at all, because of a dichotomy in the logic of argument processing. The code used 'lib_file_open' in order to find the file using the search path which, on Ghostscript, includes all the iodevices, Rom file system, RAM file system etc. That function returns a stream which the calling function 'lib_fopen' would then reach inside and pull out the pointer to the underlying gp__file *, and return, because the argument processing was written to use a gp_file *, not a stream *. But.... For the ROM file system, what we store in the 'file' member of the stream is not a gp_file *, its a 'node' *. Trying to use that as a gp_file * rapidly leads to a seg fault. So this commit reworks the argument processing to use a stream * instead of a gp_file *. In reality there is no real difference to the logic we simply use a different call. There are a lot of fiddly references to change unfortunately. There are some consequences; we need to pass stream * around instead of gp_file *, and in particular the 'encoding' functions, which are OS-specific need to use a stream *. This isn't a problem for the interpreters and graphics library, but mkromfs *also* uses those OS-specific files, and it does not have the stream library available. Rather than trying to include it, we note that we don't actually need to use these functions for mkromfs and we do the same hackery as for other missing functionality; we define a stub function that does nothing but will permit the compile to complete.
* Add text file interpreter for gpdl.Robin Watts2022-10-211-0/+5
| | | | | | | Spots ascii/utf8/utf16 and feeds to PCL interpreter. May need further tweaking with both text file spotting and font selection, but it's a decent start.
* Revise FAPI integration in PCL code.Chris Liddell2022-10-122-5/+3
| | | | | | | | | | | | | Originally, the FAPI code held a buffer of the full font data, for the duration of the life of the font object. Given that the entire font set is memory resident, three times over, for the life of the interpreter(s), that ends up holding quite a lot of memory. This changes it so it uses the font data read directly from the romfs (rather than read into a persistent memory buffer). To maintain performance, we now store the PCL fonts uncompressed in the romfs. This grows the binary from 25Mb to 29Mb.
* PCL interpreter - fix decode_glyph for UnicodeKen Sharp2022-09-271-3/+9
| | | | | | | | | | | | | | | | | | | | The text extraction (and pdfwrite family) expect that decode_glyph should always return pairs of bytes (an assumption that Unicode code points are 2 bytes), and the return value from the routine should be the number of bytes required to hold the value. The PCL decode_glyph routine however was simply returning 1, which caused the text extraction code some difficulty since it wasn't expecting that. This commit firstly alters the text extraction code to cope 'better' with a decode_glyph routine which returns an odd value (basically ignore it and fall back to using the character code). We also alter the pl_decode_glyph routine to return 2 instead of 1, so that it correctly tells the caller that it is returning 2 bytes. Finally we make sure that the returned value is big-endian, because the text extraction code assumes it will be.
* Correct PCL passthrough SEGVs.Robin Watts2022-09-201-1/+1
| | | | | | | | | | | | | | In commit 90fa745b7 (Add gpdl support for SmartOffice integration), I tweaked the way we found the PCL interpreter, so that instead of relying on it being at a fixed point in the list of interpreters, we hunted for it by name. And then I used the wrong name. Use the right name instead. I am at a loss to understand why the normal cluster tests didn't pick this up.
* Add gpdl support for SmartOffice integration.Robin Watts2022-09-193-14/+52
| | | | | No actual SmartOffice code here, just the framework for adding the (private) "SO" interpreter.
* gpdl: Ensure that -o sets -dNOPAUSE for postscript jobs.Robin Watts2022-09-161-3/+5
| | | | | Postscript jobs require NOPAUSE in the dict, not just in the main instance.
* Coverity 380513 (redux): Fix correct macro invocationChris Liddell2022-08-301-4/+4
| | | | | Previously, I changed the wrong macro invocation, this puts that back, and changes the correct instance to new macro.
* Coverity 380513: Missed a macro instance before.Chris Liddell2022-08-291-2/+2
|
* Coverity 380510/380513: Avoid redundant ID type checkChris Liddell2022-08-263-50/+55
| | | | | | | | | | Since we've already checked the font and macro ID types are string, coverity spots that the type checks in the ID accessor macros are redundant. So, add accessors for when we already know the ID is a string ID. Secondly, tidy up macro naming, so it's not so easily confused with a variable or constant value.
* Change how pdfi interacts with FAPI for Truetype fontsChris Liddell2022-07-041-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In PDF, only symbolic Truetype fonts draw marks from the glyph at GID zero (the TTF notdef). But the default TTF notdef is an empty rectangle, rather than the Postscript style non-marking glyph. The FAPI/Freetype incremental interface integration includes code to spot that case, and return an empty glyph. Since PDFs don't do incremental font definitions, the pdfi code simply passed the TTF into FAPI, and onto Freetype as a complete font, so all the glyph lookups were handled inside Freetype, not using the incremental interface. Thus we lost the ability to do that "filtering". Equally, we don't want to take the time to break down the font and "reassemble" it as the Postscript interpreter is forced to do. This implements a hybrid approach where we still pass the font data unchanged into Freetype, but we still use the incremental interface, allowing that notdef filtering to happen. This commit affects a heuristic in freetype which autmatically enables autohinting, meaning we'll no longer get autohinting in cases where we previously did. That gives a perceived drop in quality at low resolutions. Since autohinting can be enabled at the command line, it's not a serious concern.
* Bug 705156(1): Avoid double free of PCL error bufferChris Liddell2022-04-121-0/+1
|
* pcl/pcl/rtrstcmp.c:uncompress_9(): fix for bug 705155.Julian Smith2022-04-081-3/+5
| | | | Don't let <i> decrement below zero.
* Support -dNODISPLAY command line option in "pl" layerChris Liddell2022-03-181-19/+23
| | | | | | | | | | Ghostscript has "-dNODISPLAY" which is a shortcut option for: "-sDEVICE=nullpage -dBATCH -dNOPAUSE" add support for that to the "pl" layer, so other languages handle it, too. Prompted by the fix for bug 705075.
* Fix and extend chameleon device.Robin Watts2022-03-102-16/+17
| | | | | | | | | | | | | | | | | | | | | | This wasn't working, possibly due to device changes, more likely due to insufficient testing when it was first written. We fix it here, and change the way we handle post render color conversion. We were using ICC before in the case when we had a PostRenderProfile, but not otherwise. If no PostRenderProfile is specifically set, we now stash the device profile before we change our colormodel, and use that as the target for our post render conversion. This has required a new downscaler helper function to make an icc link from a given profile. This means that we now only really support contone operation (as doing ICC conversions from pre-dithered results will not look good). If we want to support dithered output, then we'll really need to do the dithering as part of the conversion from contone rendered RGB, as otherwise it'll look really bad.
* Coverity 375568: Tweak initialisation of px_args_t.Robin Watts2022-02-171-2/+1
| | | | | | | | Because args.pv[1] is non-zero, and all the rest are zero, pxSetHalftoneMethod won't access args.source, but Coverity can't see this. For clarity, we update the init of args to clear the whole lot.
* Coverity 375614: Initialise pixinfo.id to gx_no_bitmap_id.Robin Watts2022-02-171-0/+1
| | | | Certainly shouldn't hurt, and may genuinely be a bug.
* Coverity 375566: Init ref counting entry for gs_halftone (xps)Chris Liddell2022-02-171-1/+2
| | | | | | | | | | | | | | For the stack based halftone, we want to set the reference counting data to zeros/NULLs - in this case, it is later copied into an actually reference counted, heap allocated object. Equivalent to 6849cc4774817a2afa2e6f4d77c1aa63e432352f in pdf/ Coverity 375605: Init ref counting entry for gs_halftone For the stack based halftone, we want to set the reference counting data to zeros/NULLs - in this case, it is later copied into an actually reference counted, heap allocated object.
* Squash a compiler warning with debug build.Chris Liddell2022-02-171-1/+1
|
* Coverity 375727: initialise stack variableChris Liddell2022-02-171-2/+3
| | | | | In the case where it matters, we wouldn't hit it without being initialised, but Coverity can't know that, and the cost to initialise it is tiny.
* Move pcl/ sources away from gs_sprintf to gs_snprintfChris Liddell2022-02-168-26/+26
|
* Fix memory leak with PCL macros.Robin Watts2022-02-031-0/+2
| | | | | | | A PCL stream that does not complete the macro operation, can lead to memory leaks. This was spotted due to a problem where catting files in on Windows was failing to treat them as binary files, resulting in them being truncated at the first Ctrl-Z char.
* Fix memory leak.Robin Watts2022-02-031-2/+2
| | | | | | | | | | | | | | When running a windows memento, 32bit build of: gpcl6 -dNOPAUSE -dBATCH -sDEVICE=ppmraw -dMaxBitmap=1000 -r300 -o gpcl6.out ../tests_private/pcl/pcl5cats/*.BIN we'd see leaks from pl_bitmap_build_char. I could not reproduce these when running individual files. A desk-check of the code spotted that penum would not be freed if a particular error path was taken. Fixing that (as here), removes the leaks.
* pcl/pcl/: fix Memento leak of pst->args.data.Julian Smith2022-02-013-7/+11
| | | | | | | | | | | pcl_impl_process_eof(): free pcli->pst.args.data before calling process_init(). Also removed pcl_parser_init_inline() macro and replaced with explicit code in the single call site in pcl_process_init(). Fixes: ghostpdl/mem-extract-bin/gpcl6 -dNOPAUSE -dBATCH -sDEVICE=ppmraw -dMaxBitmap=1000 -r300 -o gpcl6.out tests_private/customer_tests/bug693543.pcl
* pcl/pcl/pcsfont.c:pcl_character_data(): fixed Memento leak.Julian Smith2022-01-311-22/+28
| | | | | | | | We need to free char_data if we return e_Range. Fixes 1 leaked block in: ghostpdl/mem-extract-bin/gpcl6 -dNOPAUSE -dBATCH -sDEVICE=ppmraw -dMaxBitmap=1000 -r300 -o gpcl6.out tests_private/customer_tests/HUD_noescnew.pcl
* pcl/pcl/pctop.c: pcl_impl_deallocate_interp_instance(): fixed Memento leaks.Julian Smith2022-01-271-0/+4
| | | | | | | | Added a call to pcl_pattern_free_pattern() with pcli->pcs.punsolid_pattern. Fixes 114 leaked blocks with: ghostpdl/mem-extract-bin/gpcl6 -dNOPAUSE -dBATCH -sDEVICE=ppmraw -dMaxBitmap=1000 -r300 -o gpcl6.out tests_private/customer_tests/bug689453.pcl
* Fix PCL memory leak of palette lookup table.Robin Watts2022-01-261-1/+3
| | | | | | | Seen with: gpcl6 -dNOPAUSE -dBATCH -sDEVICE=ppmraw -dMaxBitmap=1000 -r300 -o gpcl6.out ../tests_private/pcl/pcl5cfts/fts.2410
* PCL6: Fix leaking macros at shutdown.Robin Watts2022-01-261-0/+1
| | | | | | | See when running: membin/gpcl6 -dNOPAUSE -dBATCH -sDEVICE=ppmraw -dMaxBitmap=1000 -r300 -o gpcl6.out /home/regression/cluster/tests_private/pcl/pcl5cfts/fts.1100
* PCL6: Fix memory leaks on closedown of interpreter.Robin Watts2022-01-263-1/+8
| | | | | We were not clearing the bi_pattern_array, which caused lots of state to be retained.
* pcl/pcl/: pcl_impl_deallocate_interp_instance(): fixed 3 Memento leaks.Julian Smith2022-01-252-1/+6
| | | | | | | | Added a call to gx_pattern_cache_free(). Fixes 3 Memento leaks (out of 116) in: ./ghostpdl/mem-extract-bin/gpcl6 -dNOPAUSE -dBATCH -sDEVICE=ppmraw -dMaxBitmap=1000 -r300 -o gpcl6.out tests_private/customer_tests/bug692970.pcl
* pcl/pcl/pctop.c: fixed leak of two patterns dictionaries.Julian Smith2022-01-251-0/+3
| | | | | | | | | In pcl_impl_deallocate_interp_instance(), call pl_dict_release() with &pcli->pcs.gl_patterns and &pcs.pcl_patterns. Fixes Memento leak in: ./ghostpdl/mem-extract-bin/gpcl6 -dNOPAUSE -dBATCH -sDEVICE=ppmraw -dMaxBitmap=1000 -r300 -o gpcl6.out tests_private/customer_tests/bug690756.pcl
* Bug 693376: Move pjl_permanent_soft_fonts to pjl state structure.Robin Watts2022-01-211-12/+12
| | | | | Move a global to the pjl state. The global is initialised when the pjl state is allocated, so the lifespans match.
* Fix SEGV seen in alldevs test.Robin Watts2022-01-191-1/+6
| | | | | | | | | | | | | gpcl6 --debug=epo-disable -sOutputFile=out%04d.tif -dTIFFDateTime=false -dMaxBitmap=400000000 -sDEVICE=tiffsep1 -r72 -Z: -dNOPAUSE -dBATCH -K2000000 -dClusterJob ../perf-testing-gpdl/pcl/j9_acrobat.pcl was crashing. This is because pxBeginPage was putting a parameter into the device which was causing it to close. The device was then not being opened again before it was being used. The fix is simply to make the code reopen the device after all the put_paramming has completed.
* pcl/pcl/: fix leak of pcs->pwhite_cs.Julian Smith2022-01-172-1/+6
| | | | | | | | | E.g. avoids Memento leak in: ./ghostpdl/mem-extract-bin/gpcl6 -dNOPAUSE -dBATCH -sDEVICE=ppmraw -o gpcl6.out ghostpdl/pcl/examples/fills.pcl Also added added comments to encourage frgrnd_do_reset() and pcl_free_default_objects() to be kept in step with each other.
* Fix some memory leaks with gpcl6.Robin Watts2022-01-132-1/+22
| | | | | | | | | When a memento build of gpcl6 is run with no arguments, we can see that memory leaks. Here we fix some of those. Firstly, free the font directory. Secondly, free the paper type table.
* Fix PCL interpreter leaking a graphics state.Robin Watts2022-01-131-11/+22
| | | | | | | | | | | | | | | | | | | | | A memento build of pcl, run with no arguments shows significant leakage. Part of this is due to a graphics state leaking from the PCL interpreter. This appears to be because of unexpected (to me at least!) behaviour with gsave/grestore. If we make a graphics state, and then gsave, we might reasonably expect grestore to leave us back in the newly created state. This is not the case; when grestore restores, if it would leave us back at the 'topmost' gstate, it does an extra gsave. This is believed to be to do with coping with Postscript files that have more grestores than gsaves. Accordingly, we work around it here by doing an extra gs_gsave at the start, and an extra gs_restore_only at the end. This solves at least some of the leaks.
* Add pdfi to gpdlChris Liddell2021-12-071-3/+3
| | | | | Means extending the pdf_detect_language() to check the first five (rather than two) bytes in the input.
* Fix 704705 - CET file errors out incorrectly.Henry Stiles2021-11-171-7/+0
| | | | | | | Many Quality Logic tests were failing because the graphics state color space and pattern color space did not match triggering an error in the Artifex interpreter. We believe this did cause an error in earlier HP models but now it does not, so the error has been removed.
* Fix for setting of PageSpotColors Bug 704660Michael Vrhel2021-11-053-13/+11
| | | | | | | | | | | | | | | | | | | | | | | | plmain.c should not be setting the PageSpotColors value. This should be set by the individual interpreters on a per page basis. This change fixes a crash (Bug 704660) reduces the number of closing and opening times of the device with pdfi and pdfi renders more than 4 spots to the separation devices just fine. Also for gpdl with HEAD, the subsequent execution of a PS file following a PCL file did not properly reset the PageSpotColors to -1 as is required for PS files, resulting in improper output when going to a separation device. This commit includes a fix for that. Tested with command line gpdl -sDEVICE=psdcmyk -r72 -o ./myoutputs/pdl_input_%d.psd ./myinputs/owl.pcl ./myinputs/Ad_InDesign.ps ./myinputs/spots_multi_page.pdf ./myinputs/input.xps ./myinputs/deviceNImage.eps ./myinputs/DeviceN_20Colors.pdf ./myinputs/page_spots/Ad_InDesign.ps to verify that the number of spots was getting properly set with each interpreter and page (when applicable) change.
* Runtime safety of non threadsafe devices and rework globals.Robin Watts2021-11-051-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some devices within Ghostscript (currently the x11 devices, uniprint and opvp/oprp) use non const static variables, so cannot be run in multiple instances at a time. We now maintain a core "count" of how many non-threadsafe devices are being used at any time. This value can be atomically adjusted by calls to gs_lib_ctx_nts_adjust. Non threadsafe devices now call gx_init_non_threadsafe_device either as or as part of their initialise_device proc. This function attempts to increment the non-threadsafe count and fails to init if there is already a non-threadsafe device running. On success, the device finalize method is modified so that it will decrement the count at the end. The known non-threadsafe devices are updated to call this. In order to have somewhere safe to store this count, we introduce a gs_globals structure, shared between instances. Setting this up without race conditions requires some new gp_ functions that can make use of platform specific threading primitives. We have these implemented for both windows and pthread based platforms. On other platforms, we drop back to the old unsafe mechanism for counting instances. While we do this work, we take the opportunity to push the gs_memory_t pointer used for non-threadsafe debug printing into thread local storage. This enables us to remove the remaining GS_THREADSAFE guarded compilation from the source code. What is left is broadly down to allowing debugging collection for statistics, and these are now controlled by specific COLLECT_STATS_XXX defines. It is assumed that anyone wanting to collect such stats is smart enough to not try to do so while using Ghostscript in a multi-instance environment.