Writings Photos Code Contact Resume Me
Coding and hacking

You are here

Me, g++, C++ and the segfaults.

Submitted by msameer on Sun, 06/11/2005 - 3:22am

3 years ago, Alaa offered to teach me C++ to make a better mind out of my C overloaded mind.

Next day when I was practicing, I wrote my 1st C++ code and sure it had syntax errors, The result was a compiler crash.

These days I'm trying to implement something in C++, And yes, It had errors too. The result was also a crash

mohammed@uniball:~/projects/spell$ g++ -c morph.cc `pkg-config glibmm-2.4 --cflags`
In file included from morph.hh:4,
                 from morph.cc:6:
word.hh:5:18: error: glibmh: No such file or directory
word.hh:10: error: expected `)' before ‘,’ token
word.hh:13: error: ‘std::ustring’ has not been declared
word.hh:13: error: ‘std::ustring’ has not been declared
word.hh:14: error: ‘std::ustring’ has not been declared
word.hh:14: error: ‘std::ustring’ has not been declared
word.hh:14: error: ‘std::ustring’ has not been declared
word.hh:15: error: ‘ustring’ in namespace ‘std’ does not name a type
word.hh:16: error: ‘std::ustring’ has not been declared
word.hh:17: error: ‘ustring’ in namespace ‘std’ does not name a type
word.hh:18: error: ‘std::ustring’ has not been declared
word.hh:19: error: ‘ustring’ in namespace ‘std’ does not name a type
word.hh:20: error: ‘std::ustring’ has not been declared
word.hh:24: error: ‘ustring’ in namespace ‘std’ does not name a type
word.hh:25: error: ‘ustring’ in namespace ‘std’ does not name a type
word.hh:26: error: ‘ustring’ in namespace ‘std’ does not name a type
word.hh:32: error: invalid use of ‘::’
word.hh:34: error: ‘std::ustring’ has not been declared
word.hh:34: error: ‘std::ustring’ has not been declared
word.hh:35: error: ‘std::ustring’ has not been declared
word.hh:35: error: ‘std::ustring’ has not been declared
word.hh:35: error: ‘std::ustring’ has not been declared
g++: Internal error: Segmentation fault (program cc1plus)
Please submit a full bug report.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
For Debian GNU/Linux specific bug reporting instructions, see
<URL:file:///usr/share/doc/gcc-4.0/README.Bugs>.

Why do I have the feeling that I should stick to C only ? ;-)


Katoob releases.

Submitted by msameer on Fri, 04/11/2005 - 7:37am

Unless I change my mind later, Which is not going to happen IMHO, I won't release a new version.

I'll silently take a CVS snapshot and upload it to debian. Ill also keep such releases here.

This means that if you want to follow up with it you have 3 options.
1) Switch to debian.
2) Regularly update your CVS snapshot and build your binary or watch the above directory regularly. I'll also announce it here.
3) Get someone to build you a packag for your distro.

Now why is that ?
I'm lazy.
I don't feel like tagging the CVS, Generating tarballs, Building a debian package, Uploading all this to sourceforge, Updating the freshmeat record, Emailing both the arabeyes developer and announce mailing lists,Wait for the announce to be approved. Update te arabeyes project page and link to the announcement email.

Islam is using Gentoo, He's already compiling from source for phaeronix.

Debian users are handled fine ;-)

Mandrake users ? May god help them ;-)


مافيش مسرحية خلاص

Submitted by msameer on Tue, 01/11/2005 - 6:36pm

واضح ان الموضوع بتاع المسرحية كان ليه شعبية كبيرة بس انا مش هاقدر اخلى المسرحية اسبوعين زى ما وعدت

انا مسموح لى ب 40 جيجا كل شهر

خلصتهم و استخدت فوقهم كمان 40 جيجا كمان

اخر تلات ايام كان فيه 20 جيجا كل يوم

انا كنت معتمد على انهم هايبعتوالى لما اقترب من استنفاذ ماهو متاح لى لكن هم استعبطوا و طالبين منى 20 دولار

الموضوع مش موضوع فلوس
بس لما اكون اصلا بادفع 15 دولار فى الشهر يبقى هبل لما ادفع 20 دولار فى باندويدث زيادة

Best wishes,


Yet another drupal patch

Submitted by msameer on Sat, 01/10/2005 - 1:42am

The 2nd patch within a few days.
The 1st one was a few days ago and for the theme I'm using.

And looks like more people are interrested in my download.module and looks like I'll resume the development.



For the sake of the upload.module!

Submitted by msameer on Sun, 02/01/2005 - 2:23pm

I've created an issue with a patch to add the file downloads count to the upload.module, If the author kindly accepts it, I'll be moving away from the old filestore.module and start using the upload module.
As I love posting code, Here's the patch.

--- /home/mohammed/drupal-4.5/drupal-4.5.1/modules/upload.module 2004-10-20 18:57:50.000000000 +0200
+++ upload.module 2005-01-02 16:08:50.000000000 +0200
@@ -95,6 +95,8 @@
       $name = mime_header_encode($file->filename);
       // Serve images and text inline for the browser to display rather than download.
       $disposition = ereg('^(text/|image/)', $file->filemime) ? 'inline' : 'attachment';
+// We increase the downloads by one.
+db_query("UPDATE {files} SET downloads=downloads+1 WHERE fid=$file->fid");
       return array('Content-Type: '. $file->filemime .'; name='. $name,
                    'Content-Length: '. $file->filesize,
                    'Content-Disposition: '. $disposition .'; filename='. $name);
@@ -209,7 +211,7 @@
       break;
     case 'view':
       if ($node->files && user_access('view uploaded files')) {
-        $header = array(t('Attachment'), t('Size'));
+        $header = array(t('Attachment'), t('Size'), t('Downloads'));
         $rows = array();
         $previews = array();

@@ -218,7 +220,7 @@
           if ($file->list) {
             $rows[] = array(
               '<a href="/'. ($file->fid ? file_create_url($file->filepath) : url(file_create_filename($file->filename, file_create_path()))) . '">'. $file->filename .'</a>',
-              format_size($file->filesize)
+              format_size($file->filesize), ($file->downloads ? $file->downloads : 0 )
             );
             // We save the list of files still in preview for later
             if (!$file->fid) {
@@ -276,15 +278,15 @@
function upload_save($node) {
   foreach ((array)$node->files as $key => $file) {
     if ($file->source && !$file->remove) {
+      // Insert new files:
+      $fid = db_next_id('{files}_fid');
+      $file = file_save_upload($file, $file->filename);
+
       // Clean up the session:
       unset($_SESSION['file_uploads'][$file->source]);

-      // Insert new files:
-      if ($file = file_save_upload($file, $file->filename)) {
-        $fid = db_next_id('{files}_fid');
-        db_query("INSERT INTO {files} (fid, nid, filename, filepath, filemime, filesize, list) VALUES (%d, %d, '%s', '%s', '%s', %d, %d)",
-                 $fid, $node->nid, $file->filename, $file->filepath, $file->filemime, $file->filesize, $node->list[$key]);
-      }
+      db_query("INSERT INTO {files} (fid, nid, filename, filepath, filemime, filesize, downloads, list) VALUES (%d, %d, '%s', '%s', '%s', %d, 0, %d)",
+               $fid, $node->nid, $file->filename, $file->filepath, $file->filemime, $file->filesize, $node->list[$key]);
     }
     else {
       // Remove or update existing files:

You can find the proposed table change if you read the issue.


Fixed the wrong number of comments.

Submitted by msameer on Tue, 14/12/2004 - 4:01am

After fixing the spam.module, I used this code to fix the wrong statistics.

<?php
$result
= db_query("select * from node_comment_statistics");
while (
$node = db_fetch_object($result))
{
echo
"Manipulating node: ";
echo
"$node->nid";
_comment_update_node_statistics($node->nid);
echo
"<br />";
}
?>

I've posted it on the drupal forum.