summaryrefslogtreecommitdiff
path: root/src/fccache.c
AgeCommit message (Collapse)AuthorFilesLines
2009-02-13Explicitly chmod() directories (bug #18934)Behdad Esfahbod1-3/+11
Two changes: - after mkdir(), we immediately chmod(), such that we are not affected by stupid umask's. - if a directory we want to use is not writable but exists, we try a chmod on it. This is to recover from stupid umask's having affected us with older versions.
2009-02-13Consistently use FcStat() over stat() in all placesBehdad Esfahbod1-6/+1
2009-02-13[fccache] Consistently use FcStat() over stat() (bug #18195)Behdad Esfahbod1-1/+1
2007-11-13Workaround for stat() brokenness in Microsoft's C library (bug 8526)Tor Lillqvist1-1/+92
Fix a couple of longstanding problems with fontconfig on Windows that manifest themselves especially in GIMP. The root cause to the problems is in Microsoft's incredibly stupid stat() implementation. Basically, stat() returns wrong timestamp fields for files on NTFS filesystems on machines that use automatic DST switching. See for instance http://bugzilla.gnome.org/show_bug.cgi?id=154968 and http://www.codeproject.com/datetime/dstbugs.asp As fccache.c now looks at more fields in the stat struct I fill in them all. I noticed that fstat() is used only on a fd just after opening it, so on Win32 I just call my stat() replacement before opening instead... Implementing a good replacement for fstat() would be harder because the code in fccache.c wants to compare inode numbers. There are no (readily accessible) inode numbers on Win32, so I fake it with the hash of the full file name, in the case as it is on disk. And fstat() doesn't know the full file name, so it would be rather hard to come up with a inode number to identify the file. The patch also adds similar handling for the cache directory as for the fonts directory: If a cachedir element in fonts.conf contains the magic string "WINDOWSTEMPDIR_FONTCONFIG_CACHE" it is replaced at runtime with a path under the machine's (or user's) temp folder as returned by GetTempPath(). I don't want to hardcode any pathnames in a fonts.conf intended to be distributed to end-users, most of which who wouldn't know how to edit it anyway. And requiring an installer to edit it gets complicated.
2007-11-03Make file_stat argument to FcDirCacheLoadFile optional.Keith Packard1-0/+3
Allow file_stat to be NULL by using a local stat structure in that case.
2007-10-18Must not insert cache into hash table before completely validating.Keith Packard1-2/+2
The cache was inserted into the hash table before the timestamps in the cache were verified; if that verification failed, an extra pointer to the now freed cache would be left in the hash table. FcFini would fail an assertion as a result.
2007-10-18Don't use X_OK bit when checking for writable directories (bug 12438)Keith Packard1-2/+2
Some mingw versions have broken X_OK checking; instead of trying to work around this in a system-depedent manner, simply don't bother checking for X_OK along with W_OK as such cases are expected to be mistakes, and not sensible access control.
2007-10-18Comment about mmaping cache files was misleading.Keith Packard1-1/+2
2007-10-18Store font directory mtime in cache file.Keith Packard1-23/+41
Instead of relying on mtime ordering between a directory and its associated cache file, write the directory mtime into the cache file itself. This makes cache file checks more reliable across file systems. This change is made in a way that old programs can use new cache files, but new programs will need new cache files.
2007-08-05Free temporary string in FcDirCacheUnlink (Bug #11758)Keith Packard1-0/+1
In FcDirCacheUnlink(), the line cache_hashed = FcStrPlus (cache_dir, cache_base); allocates memory in cache_hashed that is never free()'d before the function exits. Reported by Ben Combee.
2006-12-02Don't use varargs CPP macros in fccache.c. (bug 8733)Kean Johnston1-6/+7
src/fccache.c uses a trick to try and use a function name that is also a macro name. It does this using the varargs args() macro. Replace that with separate macros for each number of formals.
2006-09-17More fixes for Win32 building (bug 8311)Han-Wen Nienhuys1-1/+2
Our build system barfs on autogen.sh, which ignores --noconfigure. Configure needs a host of options to make the cross compile work in our case. Fix typo in fccache.c
2006-09-17FcStrCanonFileName buggy for mingw. (bug 8311)Han-Wen Nienhuys1-0/+5
FcStrCanonFileName checks whether s[0] == '/', and recurses if not. This only works on POSIX. On dos, this crashes with a stack overflow. The patch attached splits this functionality in two functions (FcStrCanonAbsoluteFilename) and uses GetFullPathName on windows to get an absolute path. It also fixes a number of other issues. With this patch, LilyPond actually produces output on Windows.
2006-09-17Detect and use available random number generator (bug 8308)Keith Packard1-1/+12
Prefer random over lrand48 over rand
2006-09-09Insert newly created caches into reference data structure.Keith Packard1-3/+14
All caches used in the application must be in the cache reference list so internal references can be tracked correctly. Failing to have newly created caches in the list would cause the cache to be deallocated while references were still present.
2006-09-07Reference patterns in FcCacheCopySet.Keith Packard1-1/+6
As patterns are put into the font set copy, mark them as referenced so the cache stays around while the font set is in use.
2006-09-05Eliminate .so PLT entries for local symbols. (thanks to Arjan van de Ven)Keith Packard1-0/+3
Using a simple shell script that processes the public headers, two header files are constructed that map public symbols to hidden internal aliases avoiding the assocated PLT entry for referring to a public symbol. A few mistakes in the FcPrivate/FcPublic annotations were also discovered through this process
2006-09-04Correct reference count when sharing cache file objects.Keith Packard1-1/+3
Multiple maps of the same cache file share the same mapped object; bump the cache object reference count in this case
2006-09-04Make cache reference counting more efficient.Keith Packard1-0/+9
Eliminate need to reference cache object once per cached font, instead just count the number of fonts used from the cache and bump the reference count once by that amount. I think this makes this refernece technique efficient enough for use.
2006-09-04Reference count cache objects.Keith Packard1-64/+191
Caches contain patterns and character sets which are reference counted and visible to applications. Reference count the underlying cache object so that it stays around until all reference objects are no longer in use. This is less efficient than just leaving all caches around forever, but does avoid eternal size increases in case applications ever bother to actually look for changes in the font configuration.
2006-09-04Leave cache files mapped permanently.Keith Packard1-31/+112
Without reference counting on cache objects, there's no way to know when an application is finished using objects pulled from the cache. Until some kinf of cache reference counting can be done, leave all cache objects mapped for the life of the library (until FcFini is called). To mitigate the cost of this, ensure that each instance of a cache file is mapped only once.
2006-09-04Hide private functions in shared library. Export functionality for utilities.Keith Packard1-0/+48
Borrowing header stuff written for cairo, fontconfig now exposes in the shared library only the symbols which are included in the public header files. All private symbols are hidden using suitable compiler directives. A few new public functions were required for the fontconfig utility programs (fc-cat and fc-cache) so those were added, bumping the .so minor version number in the process.
2006-09-02Allow font caches to contain newer version numbersKeith Packard1-2/+2
Use the version number inside the cache file to mark backward compatible changes while continuing to reserve the filename number for incompatible changes.
2006-09-01Pass directory information around in FcCache structure. Freeze charsets.Keith Packard1-178/+122
Instead of passing directory information around in separate variables, collect it all in an FcCache structure. Numerous internal and tool interfaces changed as a result of this. Charsets are now pre-frozen before being serialized. This causes them to share across multiple fonts in the same cache.
2006-08-31Revert ABI changes from version 2.3Keith Packard1-2/+14
Accidental ABI changes and additions were discovered by looking at the differences in fontconfig.h. All of those have been reverted.
2006-08-31With no args, fc-cat now dumps all directories.Keith Packard1-6/+10
Automatically list all font directories when no arguments are given to fc-cat. Also add -r option to recurse from specified cache directories. fc-cat also now prints the cache filename in verbose mode, along with the related directory name.
2006-08-31Automatically remove invalid cache files.Keith Packard1-3/+3
Cache files for missing or more recently modified directories are automatically removed at the end of every fc-cache run.
2006-08-30Fix fc-cat again. Sigh.Keith Packard1-9/+10
Internal interfaces in cache management changed again...
2006-08-30Skip broken caches. Cache files are auto-written, don't rewrite in fc-cache.Keith Packard1-70/+78
Validate cache contents and skip broken caches, looking down cache path for valid ones. Every time a directory is scanned, it will be written to a cache file if possible, so fc-cache doesn't need to re-write the cache file. This makes detecting when the cache was generated a bit tricky, so we guess that if the cache wasn't valid before running and is valid afterwards, the cache file was written. Also, allow empty charsets to be serialized with null leaves/numbers. Eliminate a leak in FcEdit by switching to FcObject sooner. Call FcFini from fc-match to make valgrind happy.
2006-08-30FcCharSetSerialize was using wrong offset for leaves. Make fc-cat work.Keith Packard1-4/+2
FcCharSetSerialize was computing the offset to the unserialized leaf, which left it pointing at random data when the cache was reloaded. fc-cat has been updated to work with the new cache structure. Various debug messages extended to help diagnose serialization errors.
2006-08-30Rework cache files to use offsets for all data structures.Keith Packard1-350/+231
Replace all of the bank/id pairs with simple offsets, recode several data structures to always use offsets inside the library to avoid conditional paths. Exposed data structures use pointers to hold offsets, setting the low bit to distinguish between offset and pointer. Use offset-based data structures for lang charset encodings; eliminates separate data structure format for that file. Much testing will be needed; offsets are likely not detected everywhere in the library yet.
2006-08-27Fix up fc-cache and fc-cat for no global cache changes.Keith Packard1-24/+53
fc-cache and fc-cat use internal (fcint.h) APIs that have changed with the elimination of the global cache.
2006-08-27Eliminate global cache. Eliminate multi-arch cache code.Keith Packard1-943/+108
With the removal of the in-directory cache files, and the addition of per-user cache directories, there is no longer any reason to preserve the giant global cache file. Eliminating of this unifies the cache structure and simplifies the overall caching strategies greatly.
2006-08-27Add architecture to cache filename.Keith Packard1-2/+3
Make cache filenames unique by inserting the architecture name into the filename.
2006-08-27Eliminate NormalizeDir. Eliminate gratuitous stat/access calls per dir.Keith Packard1-53/+2
Normalized directory names offer protection against looped directory trees but cost enormous numbers of system calls (stat per file in the hierarchy). Also, cache file directory name contents are validated each time the directory is modified, don't re-validate every time the cache file is loaded with an access and stat call.
2006-08-27Write caches to first directory with permission. Valid cache in FcDirCacheOpen.Keith Packard1-48/+42
Previous policy was to attempt to update the cache in place and bail if that didn't work. Now, search for the first writable directory and place the cache file there instead. Furthermore, on startup, search directory list for valid cache files instead of bailing if the first found cache file wasn't valid.
2006-08-042006-08-04 Keith Packard (keithp@keithp.com) reviewed by: plamPatrick Lam1-158/+165
Make cache directories configurable. Simplify and correct some code which deals with per-directory caches.
2006-07-192006-07-19 Jon Burgess (jburgess@uklinux.net) reviewed by: plamPatrick Lam1-0/+2
Fix file-descriptor leak in FcGlobalCacheDestroy.
2006-04-27Make path names in cache files absolute (NB, cache format change) StopKeith Packard1-79/+25
permitting cache files to be stored in font dirs. Bump cache magic. Don't include /fonts.cache-2 in cache hash construction. reviewed by: Patrick Lam <plam@mit.edu>
2006-04-25Include $(top_srcdir), $(top_srcdir)/src before anything else.Patrick Lam1-1/+1
Shuffle order of includes for building out of srcdir on win32. reviewed by: plam
2006-04-19Dominic Lachowicz <cinamod@hotmail.com>Patrick Lam1-3/+20
Implement mmap-like code for Windows using MapViewOfFile.
2006-04-19Bail gracefully if the cache file does not contain enough data.Patrick Lam1-1/+18
2006-04-12Don't crash if config is null (Coverity defect #984).Patrick Lam1-2/+3
2006-04-10Fix string memory leak (Coverity defect #1823).Patrick Lam1-0/+1
Fix memory leak with hash collision (Coverity defect #1824). reviewed by: plam
2006-04-10Don't leak header in non-error case (Coverity defect #1825).Patrick Lam1-0/+2
reviewed by: plam
2006-04-10Fix double free (spotted by Coverity, CID #1965).Patrick Lam1-3/+7
Check if pattern is not null before using it (Coverity defect #1883). Fix memory leak with hash collision (Coverity defect #1829). Fix memory leak when bail cases (Coverity defect #1828). Don't leak directory name (Coverity defect #1827). reviewed by: plam
2006-04-07Patrick Lam <plam@mit.edu>Patrick Lam1-4/+70
Make fontconfig compile under MinGW: 1) remove unneeded #includes; 2) make use of mmap and sysconf conditional; 3) replace rand_r by srand/rand if needed; 4) use chsize instead of ftruncate; and 5) update libtool exports file
2006-04-06Fix intel compiler warnings: make many variables static, eliminatePatrick Lam1-5/+6
duplicate names, reduce variable scopes, unsigned/signed printf formatting. reviewed by: plam
2006-03-24Fix multiarch support (don't destroy multiarch files!)Patrick Lam1-1/+2
Require pkg-config. (Thanks Behdad; better solution wanted for libxml2 detection!) reviewed by: plam
2006-03-03Get rid of C++-style comments.Patrick Lam1-2/+2