Bug 94197 - Indirect file datasources require a .cur extension for kst to make sense of them.
Summary: Indirect file datasources require a .cur extension for kst to make sense of t...
Status: RESOLVED FIXED
Alias: None
Product: kst
Classification: Applications
Component: general (show other bugs)
Version: 1.0.0
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: kst
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-12-01 04:40 UTC by D. V. Wiebe
Modified: 2004-12-01 18:21 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Proposed fix... (585 bytes, patch)
2004-12-01 05:41 UTC, Matthew Truch
Details
Perhaps a better fix (774 bytes, patch)
2004-12-01 05:52 UTC, Matthew Truch
Details

Note You need to log in before you can comment on or make changes to this bug.
Description D. V. Wiebe 2004-12-01 04:40:17 UTC
Version:           1.0.0 (using KDE 3.3.1, compiled sources)
Compiler:          gcc version 3.3.4
OS:                Linux (i686) release 2.6.9

It seems to me it would be fairly simple to guess whether the file in question is a indirect file or not, ie. is it a smallish ASCII file that contains a valid file/path name.
Comment 1 George Staikos 2004-12-01 04:41:53 UTC
On Tuesday 30 November 2004 22:40, D.V.Wiebe wrote:
> It seems to me it would be fairly simple to guess whether the file in
> question is a indirect file or not, ie. is it a smallish ASCII file that
> contains a valid file/path name.

  This is by design presently.

Comment 2 Matthew Truch 2004-12-01 05:41:45 UTC
Created attachment 8500 [details]
Proposed fix...

Get rid of check for .cur (as it checks other aspects unique to an indirect
file as well)
Comment 3 Matthew Truch 2004-12-01 05:52:06 UTC
Created attachment 8501 [details]
Perhaps a better fix

Perhaps this is a better way...
Comment 4 George Staikos 2004-12-01 06:19:36 UTC
On Tuesday 30 November 2004 23:52, Matthew Truch wrote:
> Perhaps this is a better way...

   that should be endsWith(), not !endsWith() I think.  Or switch the values 
for ret.  Anyway, I guess it can't hurt.  Anyone object to me applying this 
style of change?  I might fudge with the numbers a bit more based on what 
other data sources (especially ASCII) return, but in principle I don't think 
it hurts anything.

Comment 5 Netterfield 2004-12-01 14:50:54 UTC
The approach seems fine...  

On December 1, 2004 12:19 am, George Staikos wrote:
> ------- You are receiving this mail because: -------
> You are the assignee for the bug, or are watching the assignee.
>
> http://bugs.kde.org/show_bug.cgi?id=94197
>
>
>
>
> ------- Additional Comments From staikos kde org  2004-12-01 06:19 -------
>
> On Tuesday 30 November 2004 23:52, Matthew Truch wrote:
> > Perhaps this is a better way...
>
>    that should be endsWith(), not !endsWith() I think.  Or switch the
> values for ret.  Anyway, I guess it can't hurt.  Anyone object to me
> applying this style of change?  I might fudge with the numbers a bit more
> based on what other data sources (especially ASCII) return, but in
> principle I don't think it hurts anything.
> _______________________________________________
> Kst mailing list
> Kst@kde.org
> https://mail.kde.org/mailman/listinfo/kst

Comment 6 Matthew Truch 2004-12-01 16:17:31 UTC
>    that should be endsWith(), not !endsWith() I think.  Or switch the values 
> for ret.  

Boy, do I feel sheepish.  Correct.  

Comment 7 George Staikos 2004-12-01 18:21:56 UTC
CVS commit by staikos: 

indirect files no longer have to end in .cur, adjust ascii to return a weaker
match percentage if it also looks like an indirect file.
FEATURE: 94197


  M +1 -1      ascii/ascii.cpp   1.28
  M +5 -3      indirect/indirect.cpp   1.12


--- kdeextragear-2/kst/kst/datasources/ascii/ascii.cpp  #1.27:1.28
@@ -364,5 +364,5 @@ int understands_ascii(KConfig *cfg, cons
       } else if (QRegExp("^[\\s]*(([Nn][Aa][Nn]|(\\-\\+)?[Ii][Nn][Ff]|[0-9\\+\\-\\.eE]+)[\\s]*)+").exactMatch(s)) {
         // a number - this may be an ascii file - assume that it is
-        return 75;
+        return QFile::exists(s.stripWhiteSpace()) ? 49 : 75;
       } else {
         return 20;

--- kdeextragear-2/kst/kst/datasources/indirect/indirect.cpp  #1.11:1.12
@@ -131,6 +131,8 @@ QStringList provides_indirect() {
 
 int understands_indirect(KConfig*, const QString& filename) {
-  if (!filename.endsWith(".cur")) { // Do we really have to do this?
-    return 0;
+  int percent = 50;
+
+  if (filename.endsWith(".cur")) { // Do we really have to do this?
+    percent = 100;
   }
 
@@ -145,5 +147,5 @@ int understands_indirect(KConfig*, const
   }
 
-  return QFile::exists(ifn.stripWhiteSpace()) ? 100 : 0;
+  return QFile::exists(ifn.stripWhiteSpace()) ? percent : 0;
 }